Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bigoen/redis-bundle
Redis bundle.
https://github.com/bigoen/redis-bundle
predis redis symfony symfony-bundle
Last synced: 3 months ago
JSON representation
Redis bundle.
- Host: GitHub
- URL: https://github.com/bigoen/redis-bundle
- Owner: bigoen
- License: mit
- Created: 2020-10-01T13:13:49.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T14:59:55.000Z (5 months ago)
- Last Synced: 2024-09-29T16:40:31.656Z (3 months ago)
- Topics: predis, redis, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
BigoenRedisBundle
==============================Setup
------------
```
composer require bigoen/redis-bundle
``````yaml
# config/packages/bigoen_redis.yamlbigoen_redis:
clients:
session:
dsn: '127.0.0.1/1'
prefix: 'demo:session:*'
namespace: 'demo:session'
monolog:
dsn: '127.0.0.1/2'
key: 'demo:monolog'
doctrine_metadata_cache:
dsn: '127.0.0.1/3'
prefix: 'demo:metadata_cache:*'
namespace: 'demo:metadata_cache'
doctrine_result_cache:
dsn: '127.0.0.1/3'
prefix: 'demo:result_cache:*'
namespace: 'demo:result_cache'
doctrine_query_cache:
dsn: '127.0.0.1/3'
prefix: 'demo:query_cache:*'
namespace: 'demo:query_cache'
doctrine_second_level_cache:
dsn: '127.0.0.1/4'
prefix: 'demo:second_level_cache:*'
```
Commands:
------------
clientName: monolog, session, doctrine_metadata_cache etc.
```
sc redis:flush {clientName}
```
Examples:
------------
RedisHelper
```php
use Bigoen\RedisBundle\Utils\RedisHelper;// create from dsn.
$helper = new RedisHelper('redis://127.0.0.1/1');
// set and add namespaces.
$helper->setNamespace("test");
$helper->addNamespace("sub");
// create redis.
$redis = $helper->getRedis();
```
RedisClientHelper
```php
use Bigoen\RedisBundle\Utils\RedisClientHelper;class TestController
{
public function __invoke(RedisClientHelper $helper)
{
// create redis.
$redis = $helper->setClient("doctrine_query_cache")->createRedis();
// get namespace or other client parameters.
$namespace = $helper->getParameter('namespace');
$redis->set("{$namespace}:key", "test");
}
}
```