File,Memcached,APC,Mongo,XCache,No Redis~

why no redis?



34.6k

There is no built-in support, but you can find it in incubator. Clone it and you can use it.

https://github.com/phalcon/incubator

Example:

            $di->set('cache', function() {

                //Connect to redis
                $redis = new \Redis();
                $redis->connect('127.0.0.1', 6379);

                //Create a Data frontend and set a default lifetime to 1 hour
                $frontend = new Phalcon\Cache\Frontend\Igbinary(array(
                        'lifetime' => 3600
                ));

                //Create the cache passing the connection
                $cache = new Phalcon\Cache\Backend\Redis($frontend, array(
                        'redis' => $redis
                ));

                return $cache;
            });


839