A Ko3 Module by John Hobbs
This module provides a Redis backed cache engine for the cache module
K3-Cache_Redis is a simple, standard module.
- Drop the source in your MODPATH folder.
- Add the module to Kohana::modules in your bootstrap.php
- Ensure you have enabled the cache module as well.
To use K3-Cache_Redis you need to configure your Redis servers in application/config/cache.php
Example Config:
<?php defined('SYSPATH') or die('No direct script access.');
return array(
'redis' => array(
'driver' => 'redis',
'servers' => array(
array(
'host' => 'localhost',
'port' => 6379,
'alias' => 'local',
),
array(
'host' => 'redis.domain.tld',
'alias' => 'remote',
),
),
);
If you provide multiple servers in your configuration the keys are hashed and safely distributed across them.
Once you have it configured, use it as you would a normal cache plugin.
Example:
Cache::instance( 'redis' )->set( 'key', 'value' );
echo Cache::instance( 'redis' )->get( 'key' );
// Prints "value"
K3-Cache_Redis uses Redisent for Redis access.
K3-Cache_Redis is licensed under the MIT License. See LICENSE for more details.