参考网址http://blog.csdn.net/wgw335363240/article/details/24469159,http://www.runoob.com/redis/redis-hashes.html

1.cmd切换到目录下:redis-server.exe redis.windows.conf

2.redis-cli.exe -h 127.0.0.1 -p 6379 。

设置键值对 set myKey abc

取出键值对 get myKey

增加到yii

'components' => [

  //file
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        //memcache
        'memcache' =>[
            'class' => 'yii\caching\MemCache',
              'servers' => [
                  [
                      'host' => 'localhost',
                      'port' => 11211,
                      'weight' => 60,
                  ],
                  // [
                  //     'host' => 'localhost',
                  //     'port' => 11211,
                  //     'weight' => 60,
                  // ],

              ],
        ],
        //Redis
        'redis' => [
            'class' => 'yii\redis\Cache',
            'redis' => [
                  'hostname' => 'localhost',
                  'port' => 6379,
                  'database' => 0,//默认有16个库0-15,如果是集群的话,只有一个0。
            ]
        ],

]

posted on 2017-06-07 23:49  allen817  阅读(115)  评论(0编辑  收藏  举报