protected function uncacheClassName($className, SegmentHandler $handler) { $handler->drop(); $dao = ClassUtils::callStaticMethod($className . '::dao'); /* @var $dao StorableDAO */ return Cache::worker($dao)->uncacheByQuery($dao->makeSelectHead()); }
protected function getLayerId() { if (!($result = Cache::me()->mark($this->className)->get($this->className))) { $result = mt_rand(1, self::MAX_RANDOM_ID); Cache::me()->mark($this->className)->set($this->className, $result, Cache::EXPIRES_FOREVER); } return '@' . $result; }
public function uncache() { foreach ($this->classNameMap as $className => $tags) { $dao = ClassUtils::callStaticMethod("{$className}::dao"); /* @var $dao StorableDAO */ $worker = Cache::worker($dao); Assert::isInstance($worker, TaggableDaoWorker::class); $worker->expireTags($tags); } }
public function uncache() { foreach ($this->classNameMap as $className => $uncaches) { list($idKeys, $tags) = $uncaches; $dao = ClassUtils::callStaticMethod("{$className}::dao"); /* @var $dao StorableDAO */ $worker = Cache::worker($dao); Assert::isInstance($worker, TaggableDaoWorker::class); $worker->expireTags($tags); foreach ($idKeys as $key) { Cache::me()->mark($className)->delete($key); } $dao->uncacheLists(); } }
protected function uncacheClassName($className, $indexKey, $intKey) { $cache = Cache::me(); $pool = SemaphorePool::me(); if ($pool->get($intKey)) { $indexList = $cache->mark($className)->get($indexKey); $cache->mark($className)->delete($indexKey); if ($indexList) { foreach (array_keys($indexList) as $key) { $cache->mark($className)->delete($key); } } $pool->free($intKey); return true; } $cache->mark($className)->delete($indexKey); return false; }
public function merge(Identifiable $object, $cacheOnly = true) { Assert::isNotNull($object->getId()); $this->checkObjectType($object); $old = Cache::worker($this)->getCachedById($object->getId()); if (!$old) { // unlikely if ($cacheOnly) { return $this->save($object); } else { $old = Cache::worker($this)->getById($object->getId()); } } if ($object === $old) { return $this->save($object); } return $this->unite($object, $old); }
protected function cacheNullById($id) { return Cache::me()->mark($this->className)->add($this->makeIdKey($id), Cache::NOT_FOUND, Cache::EXPIRES_FOREVER); }
private function checkMap($objectKey) { $pool = SemaphorePool::me(); $semKey = $this->keyToInt($this->indexKey); if (!$pool->get($semKey)) { return false; } if (!($map = Cache::me()->mark($this->className)->get($this->indexKey))) { $pool->free($semKey); return false; } if (!isset($map[$objectKey])) { $pool->free($semKey); return false; } $pool->free($semKey); return true; }
protected function updateTags($tags) { $time = microtime(true); foreach ($tags as $tag) { Cache::me()->mark(self::TAG_VERSIONS)->set($tag, $time, Cache::EXPIRES_FOREVER); } return true; }
public function getCachedData($key) { return Cache::me()->mark($this->className)->get($this->makeDataKey($key, self::SUFFIX_QUERY)); }
private function uncacheClassName($className) { if (!Cache::me()->mark($className)->increment($className, 1)) { Cache::me()->mark($className)->delete($className); } }
protected function cacheByQuery(SelectQuery $query, $object, $expires = Cache::DO_NOT_CACHE) { if ($expires !== Cache::DO_NOT_CACHE) { Cache::me()->mark($this->className)->add($this->makeQueryKey($query, self::SUFFIX_QUERY), $object, $expires); } return $object; }
public function uncacheLists() { $this->dropIdentityMap(); return Cache::worker($this)->uncacheLists(); }
/** * @return DB **/ public function rollback() { if ($this->toQueue) { $this->queue[] = 'rollback;'; } else { $this->queryRaw("rollback;\n"); } $this->transaction = false; $this->savepointList = []; Cache::setPeer($this->outOfTransactionCachePeer); $this->triggerUncacher(); return $this; }
public function drop() { return Cache::me()->delete($this->index); }
protected function gentlyGetByKey($key) { if ($this->handler->ping($this->keyToInt($key))) { return Cache::me()->mark($this->className)->get($key); } else { Cache::me()->mark($this->className)->delete($key); return null; } }
protected function uncacheClassName($className, $idKeys) { foreach ($idKeys as $key) { Cache::me()->mark($className)->delete($key); } }
protected function getCachedByQuery(SelectQuery $query) { return Cache::me()->mark($this->className)->get($this->makeQueryKey($query, self::SUFFIX_QUERY)); }