4
4
[ ![ Latest Stable Version] ( https://poser.pugx.org/blink/redis/v/stable )] ( https://packagist.org/packages/blink/redis )
5
5
[ ![ Latest Unstable Version] ( https://poser.pugx.org/blink/redis/v/unstable )] ( https://packagist.org/packages/blink/redis )
6
6
7
+ ## Features
8
+
9
+ * A Redis Client compatible with [ Predis] ( https://github.com/nrk/predis ) API
10
+ * Implemented PSR-16 SampleCache
11
+ * A Session Storage class to store sessions into redis
12
+
7
13
## Installation
8
14
9
15
You can install the latest version of blink-redis by using Composer:
@@ -12,3 +18,53 @@ You can install the latest version of blink-redis by using Composer:
12
18
composer require blink/redis:dev-master
13
19
```
14
20
21
+ ## Documentation
22
+
23
+ ### Configuring a redis service
24
+
25
+ You can easily configure a redis service in the services definition file which located to ` src/config/services.php ` by default.
26
+
27
+ The following is a sample example:
28
+
29
+ ``` php
30
+ 'redis' => [
31
+ 'class' => blink\redis\Client::class,
32
+ 'servers' => ['tcp://127.0.0.1:6379'],
33
+ ]
34
+ ```
35
+
36
+ Once the redis service configured, we can access redis server through ` app()->redis ` in our application. As
37
+ The Redis component is based on [ Predis] ( https://github.com/nrk/predis ) , you can refer their documentation on
38
+ how to issue command to redis servers.
39
+
40
+ ### Using redis as a cache service
41
+
42
+ The component provides a PSR-16 SampleCache implementation which using redis as a cache storage. We can define
43
+ a cache service in ` services.php ` likes the folowing:
44
+
45
+ ``` php
46
+ 'cache' => [
47
+ 'class' => blink\redis\cache\SampleCache::class,
48
+ 'redis' => 'redis', // The redis service to store cached data
49
+ 'prefix' => '', // The prefix of cached key
50
+ ]
51
+ ```
52
+
53
+ Once the cache service configured, we can access the cache service through ` app()->cache ` in our application.
54
+
55
+
56
+ ### Using Redis as session storage
57
+
58
+ The component also provides a Session Storgae class which allows Blink to store application sessions into redis.
59
+ we can configure the session storage in the following way:
60
+
61
+ ``` php
62
+ 'session' => [
63
+ 'class' => blink\session\Manager::class,
64
+ 'expires' => 3600 * 24 * 15,
65
+ 'storage' => [
66
+ 'class' => blink\redis\session\Storage::class,
67
+ 'redis' => 'redis', // the redis service to store sessions
68
+ ]
69
+ ],
70
+ ```
0 commit comments