CakePhp Cache清除所有模型

时间:2016-01-27 10:34:28

标签: cakephp caching memcached

我在core.php中有这个配置

 $memcacheServer =  '127.0.0.1:11211';
 $engine         =  'Memcached';
 Cache::config('default', array(
    'engine' => $engine,  
    'duration' => 3600,  
    'probability' => 100,  
    'prefix' => $prefix,  
    'servers' => array(
        $cacheServer // localhost, default port 11211
    ), //[optional]
            'groups' => array(
                'catalogs',
                'products',
                'aro',
                'aco',
                'product_categories',
                'available.cats',
                'available.prod.cats',
                'this.user.catalogs',
                'temp.comp.fetch' ,
                'uc'
 ),
    'persistent' => 'my_connection', // [optional] The name of the persistent connection.
    'compress' => true, // [optional] compress data in Memcached (slower, but uses less memory)
  ));
Cache::config('_cake_core_', array(
                'engine' => $engine,
                'servers' => array(
                    $memcacheServer // localhost, default port 11211
        ),
        'prefix' => $prefix . 'cake_core_',
        'path' => CACHE . 'persistent' . DS,            
        'duration' => $duration,
        'persistent' => 'my_connection'
));

   Cache::config('_cake_model_', array(
    'engine'  => $engine,
        'servers' => array(
                    $memcacheServer // localhost, default port 11211
        ),
    'prefix' => $prefix . 'cake_model_',
    'path'   => CACHE . 'models' . DS,
    'duration'   => $duration,
        'persistent' => 'my_connection'
));

当我保存时,在某些情况下,我会

 Cache::clearGroup('available.prod.cats');
            Cache::clearGroup('available.prod.cats');
            Cache::clearGroup('this.user.catalogs');

Cake会删除与AroAco模型相关的所有缓存模型。为什么呢?

1 个答案:

答案 0 :(得分:0)

cake cache clear_all 

在您的cmd上使用