/** * Returns general cache key indenpendent on query parameters or sql limit * Used e.g. for previously accessed columns caching * @return string */ protected function getGeneralCacheKey() { if ($this->generalCacheKey) { return $this->generalCacheKey; } return $this->generalCacheKey = md5(serialize(array(__CLASS__, $this->name, $this->sqlBuilder->getConditions()))); }
/** * Loads cache of previous accessed columns and returns it * * @internal * @return array|false */ public function getPreviousAccessed() { $cache = $this->connection->getCache(); if ($this->rows === null && $cache && !is_string($this->prevAccessed)) { $this->accessed = $this->prevAccessed = $cache->load(array(__CLASS__, $this->name, $this->sqlBuilder->getConditions())); } return $this->prevAccessed; }
/** * Returns general cache key independent on query parameters or sql limit * Used e.g. for previously accessed columns caching * @return string */ protected function getGeneralCacheKey() { if ($this->generalCacheKey) { return $this->generalCacheKey; } $key = [__CLASS__, $this->name, $this->sqlBuilder->getConditions()]; $trace = []; foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) { $trace[] = isset($item['file'], $item['line']) ? $item['file'] . $item['line'] : NULL; } $key[] = $trace; return $this->generalCacheKey = md5(serialize($key)); }
/** * Returns general cache key independent on query parameters or sql limit * Used e.g. for previously accessed columns caching * @return string */ protected function getGeneralCacheKey() { if ($this->generalCacheKey) { return $this->generalCacheKey; } $key = array(__CLASS__, $this->name, $this->sqlBuilder->getConditions()); if (!$this->generalCacheTraceKey) { $trace = array(); foreach (debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : FALSE) as $item) { $trace[] = isset($item['file'], $item['line']) ? $item['file'] . $item['line'] : NULL; } $this->generalCacheTraceKey = $trace; } $key[] = $this->generalCacheTraceKey; return $this->generalCacheKey = md5(serialize($key)); }
/** * Returns cache key for selected columns caching * @return string */ protected function getCacheKey() { return md5(serialize(array(__CLASS__, $this->name, $this->sqlBuilder->getConditions()))); }
protected function saveCacheState() { if ($this->observeCache && $this->cache && !$this->sqlBuilder->getSelect() && $this->accessedColumns != $this->previousAccessedColumns) { $this->cache->save(array(__CLASS__, $this->name, $this->sqlBuilder->getConditions()), $this->accessedColumns); } }
protected function saveCacheState() { if ($this->observeCache && ($cache = $this->connection->getCache()) && !$this->sqlBuilder->getSelect() && $this->accessed != $this->prevAccessed) { $cache->save(array(__CLASS__, $this->name, $this->sqlBuilder->getConditions()), $this->accessed); } }