scraton / sfredisplugin Goto Github PK
View Code? Open in Web Editor NEWAn extension to sfRedisPlugin that adds ORM-like functionality. Think of it as OHM for PHP.
Home Page: http://github.com/mastermix/sfRedisPlugin/tree/
License: MIT License
An extension to sfRedisPlugin that adds ORM-like functionality. Think of it as OHM for PHP.
Home Page: http://github.com/mastermix/sfRedisPlugin/tree/
License: MIT License
sfRedisPlugin ============= The sfRedis plugin provides redis support to symfony (through Predis). Installation ------------ You can install this plugin the usual way (RTFM), or if you want to work with the trunk: $ cd plugins $ svn co http://svn.symfony-project.com/plugins/sfRedisPlugin/trunk/ sfRedisPlugin Then activate the plugin in the `config/ProjectConfiguration.class.php` file. Configuration ------------- Edit `config/redis.yml` to suit your redis installation : [yml] all: connections: local: host: 127.0.0.1 port: 6379 You can also use URL based notation : [yml] all: connections: local: redis://127.0.0.1:6379 By default, there is a connection named "default" which targets a local redis server. All available parameters : [yml] all: connections: local: host: 127.0.0.1 port: 6379 database: 0 password: secret connection_timeout: 5 read_write_timeout: 30 You can also use Predis cluster feature : [yml] all: connections: myshard: - redis://192.168.0.1:6379 - redis://192.168.0.2:6379 Get a predis client ------------------- To create a connection, use `sfRedis::getClient()` with the connection name as parameter : [php] $redis = sfRedis::getClient('myshard'); Or empty to use "default" connection: [php] $redis = sfRedis::getClient(); Then follow Predis API to query the database [php] $redis->set('name', 'value'); $value = $redis->get('name'); Symfony cache ------------- The sfRedisPlugin provides a `sfRedisCache` class to use for view and/or i18n symfony cache. To enable it, edit `config/factories.yml` : [yml] all: view_cache: class: sfRedisCache param: connection: default prefix: view:%SF_APP%:%SF_ENVIRONMENT% The parameter "connection" is the key defined in `config/redis.yml`. The parameter "prefix" is adjusted in this example. Doctrine cache -------------- The sfRedisPlugin provides a Doctrine cache backend. To enable it, edit `ProjectConfiguration::configureDoctrine` with : [php] $cacheDriver = new Doctrine_Cache_Redis(array('server' => 'redis://127.0.0.1:6379', 'prefix' => 'dql:')); $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver); The option "prefix" is recommended to keep redis server keys clean. You can also pass a `Predis_Client` object as an option: [php] $redis = Predis_Client::create(...); $cacheDriver = new Doctrine_Cache_Redis(array('redis' => $redis)); $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver); Since `sfRedis::getClient` returns a `Predis_Client`, you can use configuration from your `config/redis.yml`: [php] $cacheDriver = new Doctrine_Cache_Redis(array('redis' => sfRedis::getClient('local'), 'prefix' => 'dql:')); $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver); Please note, you need to enable the `sfRedisPlugin` *before* the `sfDoctrinePlugin` to make the previous snippet work. TODO ---- * work with nginx HTTP redis module LINKS ----- * Predis http://github.com/nrk/predis * redis http://code.google.com/p/redis/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.