https://github.com/rethinkphp/blink-redis
A Redis component for the Blink Framework
https://github.com/rethinkphp/blink-redis
blink blink-framework cache php psr-16 redis
Last synced: 3 months ago
JSON representation
A Redis component for the Blink Framework
- Host: GitHub
- URL: https://github.com/rethinkphp/blink-redis
- Owner: rethinkphp
- License: mit
- Created: 2017-04-27T15:06:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-09-05T03:15:59.000Z (7 months ago)
- Last Synced: 2025-10-19T22:07:42.309Z (6 months ago)
- Topics: blink, blink-framework, cache, php, psr-16, redis
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A Redis component for the Blink Framework
[](https://travis-ci.org/rethinkphp/blink-redis)
[](https://packagist.org/packages/blink/redis)
[](https://packagist.org/packages/blink/redis)
## Features
* A Redis Client compatible with [Predis](https://github.com/nrk/predis) API
* Implemented PSR-16 SampleCache
* A Session Storage class to store sessions into redis
## Installation
You can install the latest version of blink-redis by using Composer:
```
composer require blink/redis:dev-master
```
## Documentation
### Configuring a redis service
You can easily configure a redis service in the services definition file which located to `src/config/services.php` by default.
The following is a sample example:
```php
'redis' => [
'class' => blink\redis\Client::class,
'servers' => ['tcp://127.0.0.1:6379'],
]
```
Once the redis service configured, we can access redis server through `app()->redis` in our application. As
the Redis component is based on [Predis](https://github.com/nrk/predis), you can refer their documentation on
how to issue command to redis servers.
### Using redis as a cache service
The component provides a PSR-16 SampleCache implementation which using redis as a cache storage. We can define
a cache service in `services.php` likes the folowing:
```php
'cache' => [
'class' => blink\redis\cache\SampleCache::class,
'redis' => 'redis', // The redis service to store cached data
'prefix' => '', // The prefix of cached key
]
```
Once the cache service configured, we can access the cache service through `app()->cache` in our application.
### Using redis as session storage
The component also provides a Session Storgae class which allows Blink to store application sessions into redis.
we can configure the session storage in the following way:
```php
'session' => [
'class' => blink\session\Manager::class,
'expires' => 3600 * 24 * 15,
'storage' => [
'class' => blink\redis\session\Storage::class,
'redis' => 'redis', // the redis service to store sessions
]
],
```