get() public method

public get ( integer | string $keyName, integer $lifetime = null ) : mixed
$keyName integer | string
$lifetime integer
return mixed
Example #1
0
 /**
  * Increment of given $keyName by $value
  *
  * @param  string $keyName
  * @param  int    $value
  * @return int|false
  */
 public function increment($keyName = null, $value = null)
 {
     if ($keyName === null) {
         $prefixedKey = $this->_lastKey;
     } else {
         $prefixedKey = $this->getPrefixedIdentifier($keyName);
     }
     if (!$prefixedKey) {
         return false;
     }
     $this->_lastKey = $prefixedKey;
     if (!$value) {
         $value = 1;
     }
     $aKey = $this->buildKey($prefixedKey);
     $this->db->increment($aKey, 'value', $value);
     $status = $this->db->get($aKey, $cache);
     if ($status != AerospikeDb::OK) {
         return false;
     }
     return $cache['bins']['value'];
 }
Example #2
0
 public function testShouldUseOutputFrontend()
 {
     $time = date('H:i:s');
     $frontCache = new CacheOutput(['lifetime' => 10]);
     $cache = new CacheAerospike($frontCache, $this->getConfig());
     ob_start();
     $content = $cache->start('test-output');
     $this->keys[] = 'test-output';
     $this->assertNull($content);
     echo $time;
     $obContent = ob_get_contents();
     $cache->save(null, null, null, true);
     ob_end_clean();
     $this->assertEquals($time, $obContent);
     $this->assertEquals($time, $cache->get('test-output'));
     $content = $cache->start('test-output');
     $this->assertEquals($content, $obContent);
     $this->assertEquals($content, $cache->get('test-output'));
     $keys = $cache->queryKeys();
     $this->assertEquals([0 => 'test-output'], $keys);
 }
Example #3
0
 /**
  * {@inheritdoc}
  *
  * @param string $sessionId Session variable name
  * @return string
  */
 public function read($sessionId)
 {
     return $this->db->get($sessionId, $this->lifetime);
 }