vaibhavpandeyvpz / godam
简单的 PSR-6/PSR-16 缓存实现 >= PHP 5.3。
1.1
2020-04-23 04:52 UTC
Requires
- php: ^5.3 || ^7.0
- psr/cache: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0
- predis/predis: ^1.0
Suggests
- ext-memcache
- ext-redis
- predis/predis
Provides
This package is auto-updated.
Last update: 2024-08-23 14:32:37 UTC
README
简单的 PSR-6/PSR-16 缓存实现 PHP >= 5.3。
Godam:
仓库
安装
composer require vaibhavpandeyvpz/godam
用法
<?php /** * @desc Create an instance of Godam\StoreInterface */ $store = new Godam\Store\MemoryStore(); // Or $store = new Godam\Store\FileSystemStore(__DIR__ . '/cache'); // Or $memcache = new Memcache(); $memcache->connect('localhost', 11211); $store = new Godam\Store\MemcacheStore($memcache); // Or $redis = new Predis\Client('tcp://127.0.0.1:6379'); $store = new Godam\Store\PredisStore($redis); // Or $redis = new Redis(); $redis->connect('localhost', 6379); $store = new Godam\Store\RedisStore($redis); /* * @desc Using the simpler, PSR-16 cache */ $cache = new Godam\Cache($store); $cache->set('somekey', 'somevalue', 3600 /** ttl in second(s), can be null */); $value = $cache->get('somekey'); $cache->delete('somekey'); /* * @desc Or the older, PSR-6 item pool */ $cache = new Godam\CacheItemPool($store); $item = $cache->getItem('somekey'); if ($item->isHit()) { $value = $item->get(); } else { $item->set('somevalue'); $cache->save($item); } $cache->deleteItem('somekey');
许可证
查看 LICENSE.md 文件。