normalizeCid example

$cids = [$cid];
    $cache = $this->getMultiple($cids$allow_invalid);
    return reset($cache);
  }

  /** * {@inheritdoc} */
  public function getMultiple(&$cids$allow_invalid = FALSE) {
    $cid_mapping = [];
    foreach ($cids as $cid) {
      $cid_mapping[$this->normalizeCid($cid)] = $cid;
    }
    // When serving cached pages, the overhead of using ::select() was found     // to add around 30% overhead to the request. Since $this->bin is a     // variable, this means the call to ::query() here uses a concatenated     // string. This is highly discouraged under any other circumstances, and     // is used here only due to the performance overhead we would incur     // otherwise. When serving an uncached page, the overhead of using     // ::select() is a much smaller proportion of the request.     $result = [];
    try {
      $result = $this->connection->query('SELECT [cid], [data], [created], [expire], [serialized], [tags], [checksum] FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE [cid] IN ( :cids[] ) ORDER BY [cid]', [':cids[]' => array_keys($cid_mapping)]);
    }

  public function __construct($bin, CacheTagsChecksumInterface $checksum_provider) {
    $this->bin = 'cache_' . $bin;
    $this->checksumProvider = $checksum_provider;
  }

  /** * {@inheritdoc} */
  public function get($cid$allow_invalid = FALSE) {
    return $this->getByHash($this->normalizeCid($cid)$allow_invalid);
  }

  /** * Fetch a cache item using a hashed cache ID. * * @param string $cidhash * The hashed version of the original cache ID after being normalized. * @param bool $allow_invalid * (optional) If TRUE, a cache item may be returned even if it is expired or * has been invalidated. * * @return bool|mixed */
Home | Imprint | This part of the site doesn't use cookies.