MemCache supports both memcache and memcached. By setting [[useMemcached]] to be true or false, one can let MemCache to use either memcached or memcache, respectively. MemCache can be configured with a list of memcache servers by settings its [[servers]] property. By default, MemCache assumes there is a memcache server running on localhost at port 11211. See Cache for common cache operations that MemCache supports. Note, there is no security measure to protected data in memcache. All data in memcache can be accessed by any process running in the system. To use MemCache as the cache application component, configure the application as follows, php [ 'components' => [ 'cache' => [ 'class' => 'yii\caching\MemCache', 'servers' => [ [ 'host' => 'server1', 'port' => 11211, 'weight' => 60, ], [ 'host' => 'server2', 'port' => 11211, 'weight' => 40, ], ], ], ], ] In the above, two memcache servers are used: server1 and server2. You can configure more properties of each server, such as persistent, weight, timeout. Please see MemCacheServer for available options. For more details and usage information on Cache, see the guide article on caching.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Cache
コード例 #1
0
 /**
  * Initialize the component.
  */
 public function init()
 {
     $this->setServers($this->loadNodesConfigurations());
     parent::init();
 }
コード例 #2
0
ファイル: MemCache.php プロジェクト: kaihatsusha/kpimon
 /**
  * Initializes this application component.
  * It creates the memcache instance and adds memcache servers.
  */
 public function init()
 {
     $this->keyPrefix = \Yii::$app->id;
     return parent::init();
 }
コード例 #3
0
ファイル: MyCache.php プロジェクト: gtyd/jira
 public function delete($key)
 {
     CacheVisitLogService::put(CacheVisitLogService::DO_DEL, $key);
     \Yii::$app->slavecache->delete($key);
     return parent::delete($key);
 }
コード例 #4
0
ファイル: redjik.php プロジェクト: Redjik/angular-test
<?php

return ['components' => ['db' => ['class' => 'yii\\db\\Connection', 'dsn' => 'mysql:host=localhost;dbname=toptal', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'enableSchemaCache' => true, 'schemaCacheDuration' => 30], 'cache' => ['class' => \yii\caching\MemCache::className(), 'useMemcached' => true]]];
コード例 #5
0
ファイル: SessionCache.php プロジェクト: gtyd/jira
 public function delete($key)
 {
     \Yii::$app->slavecache->delete($key);
     return parent::delete($key);
 }
コード例 #6
0
ファイル: MyCache2.php プロジェクト: gtyd/jira
 public function delete($key)
 {
     return parent::delete($key);
 }