Skip to content

farmad/cakephp-redis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cakephp-redis

Redis DataSource Plugin for CakePHP

Requirements

Installation

cd app/Plugin
git clone [email protected]:nanapi/cakephp-redis.git Redis

app/Config/bootstrap.php

CakePlugin::load('Redis');

app/Config/database.php

<?php

class DATABASE_CONFIG {

  public $redis = array(
    'datasource' => 'Redis.RedisSource',
    'host' => 'localhost',
    'port' => '6379',
    'db' => '0'
  );

How to use it

your model

<?php

App::uses('RedisModel', 'Redis.Model');
class MyRedis extends RedisModel {
}

your controller

<?php
App::uses('AppController', 'Controller');
class MyController extends AppController {
  public $uses = array(
    'MyRedis';
  );

  public function index() {
    $this->MyRedis->set('key', 'value');
    $this->MyRedis->get('key');

    $this->MyRedis->incr('pv');
  }
}

Methods

This is a wrapper for phpredis. For a list of methods that can be used by the Model, please refer to the README for phpredis.

About

Redis DataSource Plugin for CakePHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published