Exemple #1
0
 /**
  * delSessionRef - delete sessions containing a specific reference
  *
  * @param  string  $ref
  * @return boolean
  */
 public function delSessionRef($ref)
 {
     $refs = $this->cache->X()->HGETALL($this->cache_ref_key);
     $keys = array($this->cache_ref_key);
     if (is_array($refs)) {
         foreach ($refs as $key => $data) {
             list($reference, $expiry) = explode('|', $data);
             if ($reference == $ref) {
                 $keys[] = $key;
             }
         }
     }
     if (count($keys) > 1) {
         $redis = $this->cache->X();
         call_user_func_array(array($redis, 'HDEL'), $keys);
         array_shift($keys);
         return (bool) $this->cache->delete($keys);
     } else {
         return false;
     }
 }
Exemple #2
0
<?php

require_once '../../MPLT.php';
$timer = new MPLT();
/**
 * using composer autoloader PSR-0
 */
require_once '../../src/dalmp.php';
$cache = new DALMP\Cache\Redis('127.0.0.1', 6379);
$cache->set('mykey', 'xpto', 300);
var_dump($cache->get('mykey'));
$cache->X()->HSET('myhash', 'field1', 'hello');
var_dump($cache->X()->HGET('myhash', 'field1'));
var_dump($cache->X()->HGETALL('myhash'));
#------------------------------------------------------------------------------
echo PHP_EOL, str_repeat('-', 80), PHP_EOL, 'Time: ', $timer->getPageLoadTime(), ' - Memory: ', $timer->getMemoryUsage(1), PHP_EOL, str_repeat('-', 80), PHP_EOL;