KeyValue
KeyValue, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist stevenlei/yii2-keyvalue "^1.0.0"
or add, (*4)
"stevenlei/yii2-keyvalue": "^1.0.0"
to the require section of your composer.json
file., (*5)
Usage
Configuration, (*6)
Add cache
configuration:, (*7)
Use FileCache
, (*8)
return [
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
]
]
or Memcache
, (*9)
return [
'components' => [
'class' => 'yii\caching\MemCache',
'keyPrefix' => '',
'useMemcached' => true,
'servers' => [
[
'host' => '127.0.0.1',
'port' => 11211,
//'weight' => 60
],
],
]
]
or Redis
, (*10)
return [
'components' => [
'class' => 'yii\redis\Cache',
'redis' => [
'hostname' => '127.0.0.1',
'port' => 6379,
'database' => 0,
]
]
]
]
Add modules configuration:, (*11)
return [
'modules' => [
'kv' => [
'class' => 'stevenlei\keyvalue\Module',
],
],
];
migrations:, (*12)
yii migrate --migrationPath=@stevenlei/keyvalue/migrations
You can then access KeyValue manager through the following URL:, (*13)
http://localhost/kv/key-value/index