PHP code example of vaibhavpandeyvpz / godam

1. Go to this page and download the library: Download vaibhavpandeyvpz/godam library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vaibhavpandeyvpz / godam example snippets




/**
 * @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');