本文整理匯總了PHP中DboSource::methodCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::methodCache方法的具體用法?PHP DboSource::methodCache怎麽用?PHP DboSource::methodCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::methodCache方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFieldsCacheKeyWithSchemanameChange
/**
* test that fields() method cache detects schema name changes
*
* @return void
*/
public function testFieldsCacheKeyWithSchemanameChange()
{
if ($this->db instanceof Postgres || $this->db instanceof Sqlserver) {
$this->markTestSkipped('Cannot run this test with SqlServer or Postgres');
}
Cache::delete('method_cache', '_cake_core_');
DboSource::$methodCache = array();
$Article = ClassRegistry::init('Article');
$ds = $Article->getDataSource();
$ds->cacheMethods = true;
$first = $ds->fields($Article);
$Article->schemaName = 'secondSchema';
$ds = $Article->getDataSource();
$ds->cacheMethods = true;
$second = $ds->fields($Article);
$this->assertEquals(2, count(DboSource::$methodCache['fields']));
}
示例2: cacheMethod
/**
* Cache a value into the methodCaches. Will respect the value of DboSource::$cacheMethods.
* Will retrieve a value from the cache if $value is null.
*
* If caching is disabled and a write is attempted, the $value will be returned.
* A read will either return the value or null.
*
* @param string $method Name of the method being cached.
* @param string $key The keyname for the cache operation.
* @param mixed $value The value to cache into memory.
* @return mixed Either null on failure, or the value if its set.
*/
public function cacheMethod($method, $key, $value = null) {
if ($this->cacheMethods === false) {
return $value;
}
if (empty(self::$methodCache)) {
self::$methodCache = Cache::read('method_cache', '_cake_core_');
}
if ($value === null) {
return (isset(self::$methodCache[$method][$key])) ? self::$methodCache[$method][$key] : null;
}
$this->_methodCacheChange = true;
return self::$methodCache[$method][$key] = $value;
}
示例3: _clearCache
protected function _clearCache()
{
DboSource::$methodCache = array();
$keys = Cache::configured();
foreach ($keys as $key) {
Cache::clear(false, $key);
}
ClassRegistry::flush();
}
示例4: _clearCache
/**
* Clear all caches present related to models
*
* Before the 'after' callback method be called is needed to clear all caches.
* Without it any model operations will use cached data instead of real/modified
* data.
*
* @return void
*/
protected function _clearCache()
{
// Clear the cache
DboSource::$methodCache = array();
$keys = Cache::configured();
foreach ($keys as $key) {
Cache::clear(false, $key);
}
ClassRegistry::flush();
// Refresh the model, in case something changed
if ($this->Version instanceof MigrationVersion) {
$this->Version->initVersion();
}
}
示例5: _clearCache
/**
* Clear all caches present related to models
*
* Before the 'after' callback method be called is needed to clear all caches.
* Without it any model operations will use cached data instead of real/modified
* data.
*
* @return void
*/
protected function _clearCache()
{
// Clear the cache
DboSource::$methodCache = array();
$keys = Cache::configured();
foreach ($keys as $key) {
Cache::clear(false, $key);
}
ClassRegistry::flush();
// Refresh the model, in case something changed
$options = array('class' => 'Migrations.SchemaMigration', 'ds' => $this->connection);
$this->Version->Version =& ClassRegistry::init($options);
$this->Version->Version->setDataSource($this->connection);
}