예제 #1
0
 /**
  * @param BlockData $blockData
  */
 public function applyBlock(BlockData $blockData)
 {
     $this->db->updateUtxoSet($this->outpointSerializer, $blockData);
     if ($this->caching) {
         foreach ($this->cacheHits as $key) {
             $this->set->delete($key);
         }
         foreach ($blockData->remainingNew as $c => $utxo) {
             $new = $this->outpointSerializer->serialize($utxo->getOutPoint())->getBinary();
             $this->set->save($new, [$utxo->getOutput()->getValue(), $utxo->getOutput()->getScript()->getBinary()], 500000);
         }
         echo "Inserts: " . count($blockData->remainingNew) . " | Deletes: " . count($blockData->requiredOutpoints) . " | " . "CacheHits: " . count($this->cacheHits) . PHP_EOL;
         $this->cacheHits = [];
     }
 }
예제 #2
0
파일: Flexistore.php 프로젝트: kisma/kisma
 /**
  * Puts data into the cache.
  *
  * $id can be specified as an array of key-value pairs: array( 'alpha' => 'xyz', 'beta' => 'qrs', 'gamma' => 'lmo', ... )
  *
  *
  * @param string|array $id       The cache id or array of key-value pairs
  * @param mixed        $data     The cache entry/data.
  * @param int          $lifeTime The cache lifetime. Sets a specific lifetime for this cache entry. Defaults to 0, or "never expire"
  *
  * @return boolean|boolean[] TRUE if the entry was successfully stored in the cache, FALSE otherwise.
  */
 public function set($id, $data = null, $lifeTime = self::DEFAULT_CACHE_TTL)
 {
     if (is_array($id) && null === $data) {
         $_result = array();
         foreach ($id as $_key => $_value) {
             $_result[$_key] = $this->_store->save($_key, $_value, $lifeTime);
         }
         return $_result;
     }
     return $this->_store->save($id, $data, $lifeTime);
 }
예제 #3
0
 public function save($prefix, $id, $data, $life_time = 0)
 {
     $this->redis_cache->setNamespace($prefix);
     return $this->redis_cache->save($id, $data, $life_time);
 }