mp3000mp / redis-client
简单易用的类,无需依赖即可封装 Redis 扩展。
0.1
2020-11-01 12:09 UTC
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- php-coveralls/php-coveralls: ^2.4
- phpstan/phpstan: ^0.12.48
- phpunit/phpunit: ^9.4
This package is auto-updated.
Last update: 2024-09-29 05:42:54 UTC
README
简单易用的类,无需依赖即可封装 Redis 扩展。
目录
安装
composer require mp3000mp/redis-client
使用
// This will try to connect and throw a RedisClientException if connection failed $client = new RedisClient($host, $port, $auth); // simple get set system $client->set('key', 'value'); $val = $client->get('key'); // this value will be converted into json text into redis $client->set('key_array', ['test' => 'test']); // returns '{"test":"test"}' $client->get('key_array'); // returns ['test' => 'test'] $client->get('key_array', true); // this key will live 120 seconds $client->set('key', 'test', 120); $client->delete('key'); // close connection $client->close();
与 Symfony 一起使用
将此添加到 services.yml
Mp3000mp\RedisClient\RedisClient: arguments: ['%env(REDIS_HOST)%', '%env(REDIS_PORT)%', '%env(REDIS_AUTH)%']