承接 peloncano/cakephp-plugin-redis-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

peloncano/cakephp-plugin-redis-cache

Composer 安装命令:

composer require peloncano/cakephp-plugin-redis-cache

包简介

A CakePHP 2.0 plugin enabling Redis (http://redis.io/) backed sessions and caching. Uses the Predis (https://github.com/nrk/predis) library to communicate with Redis.

README 文档

README

A CakePHP 2.x plugin enabling Redis backed sessions and caching. Uses the Predis library to communicate with Redis.

Had to resurrect this plugin for a legacy project that needed to connect to redis via TLS/SSL.

Installation

Run composer command

composer require peloncano/cakephp-plugin-redis-cache

Initial setup required

The plugin includes its own bootstrap.php file which must be loaded in the application app/Config/bootstrap.php file like so:

CakePlugin::load(array('RedisCache' => array('bootstrap' => true)));

The plugin will, by default, communicate with a Redis server setup on localhost at port 6379 with no password. However you may use remote Redis servers if desired. You can also configure different servers for caching and session duties as the exact configuration of these may be slightly different for best performance.

Using for Caching:

Connection configuration

if loading a configuration file (Doc):

$config['RedisCache'] = array(
    'cache' => array(
        'password' => '',
        'port' => 6379,
        'database' => 0
    )
);

If TLS/SSL is needed:

$config['RedisCache'] = array(
    'cache' => array(
        'scheme' => 'tls',
        'ssl' => ['verify_peer' => false], // any other predis SSL related options here
        'host' => 'localhost',
        'password' => '',
        'port' => 6379, // could be different for tls connections
        'database' => 0
    )
);

In app/Config/bootstrap.php you can now configure your cache

Note: Make sure this is done after the loading of the plugin

Cache::config('default', array('engine' => 'RedisCache.Redis'));

// with prefix and duration
Cache::config('other_cache_with_prefix', array(
		'engine' => 'RedisCache.Redis', 
		'prefix' => 'other_cache_with_prefix', 
		'duration'=> '+1 week'
));
	
// `throwExceptions` set to TRUE will throw exceptions on redis connection issues
// by default this is FALSE which will allow the app to continue working if caching fails
// due to redis/predis connection issues
Cache::config('other_cache', array(
		'engine' => 'RedisCache.Redis', 
		'throwExceptions' => true
));

Using for Session handling (PENDING):

In app/Config/core.php under the session configuration section:

Configure::write('Session', array(
        'cookie' => {{YOUR COOKIE NAME HERE}}
        , 'timeout' => 60
        , 'handler' => array(
            'engine' => 'RedisCache.RedisSession'
        )
	));

Global Prefix

You can add a global prefix to namespace all keys by adding the following lines right after the plugin is loaded.

For Cache:

RedisConfig::$globalCachePrefix = Inflector::slug('my app cache prefix') . ':'; // use ':' to group keys in redis

For Session:

RedisConfig::$globalSessionPrefix= Inflector::slug('my app session prefix') . ':'; // use ':' to group keys in redis

Note: This would apply before any cache specific prefix

统计信息

  • 总下载量: 526
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固