/** * @param OutPointInterface[] $requiredOutpoints * @return UtxoInterface[] */ public function fetchView(array $requiredOutpoints) { try { $utxos = []; $required = []; $cacheHits = []; foreach ($requiredOutpoints as $c => $outpoint) { $key = $this->outpointSerializer->serialize($outpoint)->getBinary(); if ($this->set->contains($key)) { list($value, $scriptPubKey) = $this->set->fetch($key); $cacheHits[] = $key; $utxos[] = new Utxo($outpoint, new TransactionOutput($value, new Script(new Buffer($scriptPubKey)))); } else { $required[] = $outpoint; } } if (empty($required) === false) { $utxos = array_merge($utxos, $this->db->fetchUtxoDbList($this->outpointSerializer, $required)); } if ($this->caching) { $this->cacheHits = $cacheHits; } return $utxos; } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL; throw new \RuntimeException('Failed to find UTXOS in set'); } }
/** * Fetches an entry from the cache. * * @param string $id The id of the cache entry to fetch * @param mixed $defaultValue The default value if $id not found * @param bool $remove * * @return mixed The cached data or FALSE, if no cache entry exists for the given id. */ public function get($id, $defaultValue = null, $remove = false) { if (false === ($_data = $this->_store->fetch($id))) { if (!$remove) { $this->_store->save($id, $_data = $defaultValue); } } elseif ($remove) { $this->_store->delete($id); } return $_data; }
public function fetch($prefix, $id) { $this->redis_cache->setNamespace($prefix); return $this->redis_cache->fetch($id); }