/** * Get value from cache for the given key * @param string $key */ private static function getFromCache($key, $roleCacheDirtyAt) { if (!self::useCache()) { return null; } self::$cacheStores = array(); $cacheLayers = kCacheManager::getCacheSectionNames(kCacheManager::CACHE_TYPE_PERMISSION_MANAGER); foreach ($cacheLayers as $cacheLayer) { $cacheStore = kCacheManager::getCache($cacheLayer); if (!$cacheStore) { continue; } $cacheRole = $cacheStore->get(self::getCacheKeyPrefix() . $key); // try to fetch from cache if (!$cacheRole || !isset($cacheRole['updatedAt']) || $cacheRole['updatedAt'] < $roleCacheDirtyAt) { self::$cacheStores[] = $cacheStore; continue; } $map = $cacheStore->get(self::getCacheKeyPrefix() . $cacheRole['mapHash']); // try to fetch from cache if (!$map) { self::$cacheStores[] = $cacheStore; continue; } KalturaLog::debug("Found a cache value for key [{$key}] map hash [" . $cacheRole['mapHash'] . "] in layer [{$cacheLayer}]"); self::storeInCache($key, $cacheRole, $map); // store in lower cache layers self::$cacheStores[] = $cacheStore; return $map; } KalturaLog::debug("No cache value found for key [{$key}]"); return null; }
/** * Get value from cache for the given key * @param string $key */ private static function getFromCache($key, $roleCacheDirtyAt) { if (!self::useCache()) { return null; } self::$cacheStores = array(); foreach (self::$cacheLayers as $cacheLayer) { $cacheStore = kCacheManager::getCache($cacheLayer); if (!$cacheStore) { continue; } $value = $cacheStore->get(self::getCacheKeyPrefix() . $key); // try to fetch from cache if (!$value || !isset($value['updatedAt']) || $value['updatedAt'] < $roleCacheDirtyAt) { self::$cacheStores[] = $cacheStore; continue; } KalturaLog::debug("Found a cache value for key [{$key}] in layer [{$cacheLayer}]"); self::storeInCache($key, $value); // store in lower cache layers self::$cacheStores[] = $cacheStore; // cache is updated - init from cache unset($value['updatedAt']); return $value; } KalturaLog::debug("No cache value found for key [{$key}]"); return null; }