wangxu / snowslide
There is no license information available for the latest version (1.3) of this package.
解决redis高并发场景下获取key值造成的雪崩问题
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
1.3
2021-11-22 09:05 UTC
Requires
- php: >=7.0
- ext-redis: *
This package is not auto-updated.
Last update: 2025-09-09 22:58:50 UTC
README
介绍
- 解决redis高并发场景下获取key值造成的雪崩问题
- 地址
安装
composer require wangxu/snowslide
使用
use Wx\Snowslide\RedisClient;
$redis = new RedisClient();
$redis->connect('127.0.0.1');
$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
// 设置请求超时时间,默认10s
$redis->setReqTimeout(6);
// 安全获取key值 get
$value = $redis->safelyGet('key', [object, method], [$param1, $param2], 1000);
var_dump($value);
$value = $redis->safelyGet('key', function, [$param1, $param2], 1000);
var_dump($value);
// 安全获取hash值 hGet
$value = $redis->safelyHGet('key', 'hashKey', [object, method], [$param1, $param2], 1000);
var_dump($value);
$value = $redis->safelyHGet('key', 'hashKey', function, [$param1, $param2], 1000);
var_dump($value);
// 安全获取hash值 hGetAll
$value = $redis->safelyHGetAll('key', [object, method], [$param1, $param2], 1000);
var_dump($value);
$value = $redis->safelyHGetAll('key', function, [$param1, $param2], 1000);
var_dump($value);
联系方式
邮箱:wangxu999999999@126.com