Работая с Doctrine, я обнаружил, что у меня есть много поисковых запросов на мой сервер Redis через Doctrine, которые запрашивают метаданные класса.Поэтому я выбрал собственный CacheProvider и переписал функцию doFetchMultiple.Но вызов ClassMetadata никогда не попадает в эту функцию.Я думал, что если я сделаю доктрину «addSelect», ему теперь понадобятся метаданные этого класса и сделать doFetchMultiple.Поэтому мне интересно, можно ли сказать Doctrine, что он должен загружать эти ClassMetadata с fetchMultiple?
class CacheProvider extends \Doctrine\Common\Cache\CacheProvider
{
const CACHE = 'cache';
/**
* Fetches an entry from the cache.
*
* @param string $id The id of the cache entry to fetch.
*
* @return mixed|false The cached data or FALSE, if no cache entry exists for the given id.
*/
protected function doFetch( $id )
{
//i always land here !!!!?
return Cache::get($id, self::CACHE);
}
/**
* Tests if an entry exists in the cache.
*
* @param string $id The cache id of the entry to check for.
*
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
*/
protected function doContains( $id )
{
return Cache::exists($id, self::CACHE);
}
/**
* Puts data into the cache.
*
* @param string $id The cache id.
* @param string $data The cache entry/data.
* @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
* cache entry (0 => infinite lifeTime).
*
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
*/
protected function doSave( $id, $data, $lifeTime = 0 )
{
return Cache::set($id, $data, $lifeTime, self::CACHE);
}
/**
* Deletes a cache entry.
*
* @param string $id The cache id.
*
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
*/
protected function doDelete( $id )
{
return Cache::delete($id, self::CACHE);
}
/**
* Flushes all cache entries.
*
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
*/
protected function doFlush()
{
return Cache::flush(self::CACHE);
}
/**
* Retrieves cached information from the data store.
*
* @since 2.2
*
* @return array|null An associative array with server's statistics if available, NULL otherwise.
*/
protected function doGetStats()
{
return Cache::getStats(self::CACHE);
// TODO: Implement doGetStats() method.
}
protected function doFetchMultiple( array $keys )
{
return Cache::getMultiple($keys, self::CACHE);
}