vaibhavpandeyvpz / godam
Simple PSR-6/PSR-16 cache implementations >= 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-11-23 15:01:23 UTC
README
Simple PSR-6/PSR-16 cache implementations PHP >= 5.3.
Godam:
गोदाम
(Warehouse)
Install
composer require vaibhavpandeyvpz/godam
Usage
<?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
See LICENSE.md file.