Skip to content

Commit 8610201

Browse files
committed
support php74
1 parent 2f7bd17 commit 8610201

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

.github/workflows/CI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- "8.2"
1818
- "8.1"
1919
- "8.0"
20+
- "7.4"
2021
steps:
2122
- uses: actions/checkout@v3
2223
- uses: shivammathur/setup-php@v2

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"source": "https://github.com/workbunny/webman-shared-cache"
1616
},
1717
"require": {
18-
"php": "^8.0",
18+
"php": ">=7.4",
1919
"ext-apcu": "*"
2020
},
2121
"require-dev": {

src/Traits/BasicMethods.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
/**
99
* @method static bool Set(string $key, mixed $value, array $optional = []) 设置缓存值
10-
* @method static mixed Get(string $key, mixed $default = null) 获取缓存值
10+
* @method static Get(string $key, mixed $default = null) 获取缓存值
1111
* @method static array Del(string ...$keys) 移除缓存
1212
* @method static array Keys(null|string $regex = null) 获取缓存键
13-
* @method static bool|int|float Incr(string $key, int|float $value = 1, int $ttl = 0) 自增
14-
* @method static bool|int|float Decr(string $key, int|float $value = 1, int $ttl = 0) 自减
13+
* @method static bool|int|float Incr(string $key, $value = 1, int $ttl = 0) 自增
14+
* @method static bool|int|float Decr(string $key, $value = 1, int $ttl = 0) 自减
1515
* @method static array Exists(string ...$keys) 判断缓存键
1616
*
1717
* @method static void Search(string $regex, Closure $handler, int $chunkSize = 100) 搜索键值 - 正则匹配
@@ -199,7 +199,7 @@ protected static function _Atomic(string $lockKey, Closure $handler, bool $block
199199
* ]
200200
* @return bool
201201
*/
202-
protected static function _Set(string $key, mixed $value, array $optional = []): bool
202+
protected static function _Set(string $key, $value, array $optional = []): bool
203203
{
204204
$ttl = intval($optional['EX'] ?? (isset($optional['EXAT']) ? ($optional['EXAT'] - time()) : 0));
205205
if (in_array('NX', $optional)) {
@@ -234,7 +234,7 @@ protected static function _Set(string $key, mixed $value, array $optional = []):
234234
* @param int $ttl
235235
* @return bool|int|float
236236
*/
237-
protected static function _Incr(string $key, int|float $value = 1, int $ttl = 0): bool|int|float
237+
protected static function _Incr(string $key, $value = 1, int $ttl = 0)
238238
{
239239
$func = __FUNCTION__;
240240
$result = false;
@@ -265,7 +265,7 @@ protected static function _Incr(string $key, int|float $value = 1, int $ttl = 0)
265265
* @param int $ttl
266266
* @return bool|int|float
267267
*/
268-
protected static function _Decr(string $key, int|float $value = 1, int $ttl = 0): bool|int|float
268+
protected static function _Decr(string $key, $value = 1, int $ttl = 0)
269269
{
270270
$func = __FUNCTION__;
271271
$result = false;
@@ -308,7 +308,7 @@ protected static function _Exists(string ...$key): array
308308
* @param mixed|null $default
309309
* @return mixed
310310
*/
311-
protected static function _Get(string $key, mixed $default = null): mixed
311+
protected static function _Get(string $key, $default = null)
312312
{
313313
$res = apcu_fetch($key, $success);
314314
return $success ? $res : $default;
@@ -331,7 +331,7 @@ protected static function _Del(string ...$keys): array
331331
* @param string|null $regex
332332
* @return array
333333
*/
334-
protected static function _Keys(null|string $regex = null): array
334+
protected static function _Keys(?string $regex = null): array
335335
{
336336
$keys = [];
337337
if ($info = apcu_cache_info()) {

src/Traits/ChannelMethods.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait ChannelMethods
4040
* @param float|int $interval
4141
* @return void
4242
*/
43-
public static function SetChannelListenerInterval(float|int $interval): void
43+
public static function SetChannelListenerInterval($interval): void
4444
{
4545
self::$interval = $interval;
4646
}
@@ -102,7 +102,7 @@ protected static function _GetChannel(string $key): array
102102
* @param bool $store 在没有监听器时是否进行储存
103103
* @return bool
104104
*/
105-
protected static function _ChPublish(string $key, mixed $message, bool $store = true, null|string|int $workerId = null): bool
105+
protected static function _ChPublish(string $key, $message, bool $store = true, $workerId = null): bool
106106
{
107107
$func = __FUNCTION__;
108108
$params = func_get_args();
@@ -185,7 +185,7 @@ protected static function _ChPublish(string $key, mixed $message, bool $store =
185185
* @param Closure $listener = function(string $channelName, string|int $workerId, mixed $message) {}
186186
* @return bool|int 监听器id
187187
*/
188-
protected static function _ChCreateListener(string $key, string|int $workerId, Closure $listener): bool|int
188+
protected static function _ChCreateListener(string $key, $workerId, Closure $listener)
189189
{
190190
$func = __FUNCTION__;
191191
$result = false;
@@ -243,7 +243,7 @@ protected static function _ChCreateListener(string $key, string|int $workerId, C
243243
});
244244
};
245245
// 设置回调
246-
$channel[$workerId]['futureId'] = self::$_listeners[$key] = $result = Future::add($callback, interval: self::$interval);
246+
$channel[$workerId]['futureId'] = self::$_listeners[$key] = $result = Future::add($callback, [], self::$interval);
247247
$channel[$workerId]['value'] = [];
248248
// 如果存在默认数据
249249
if ($default = $channel['--default--']['value'] ?? []) {
@@ -271,7 +271,7 @@ protected static function _ChCreateListener(string $key, string|int $workerId, C
271271
* @param bool $remove 是否移除消息
272272
* @return void
273273
*/
274-
protected static function _ChRemoveListener(string $key, string|int $workerId, bool $remove = false): void
274+
protected static function _ChRemoveListener(string $key, $workerId, bool $remove = false): void
275275
{
276276
$func = __FUNCTION__;
277277
$params = func_get_args();

src/Traits/HashMethods.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait HashMethods
2727
* @param int $ttl
2828
* @return bool
2929
*/
30-
protected static function _HSet(string $key, string|int $hashKey, mixed $hashValue, int $ttl = 0): bool
30+
protected static function _HSet(string $key, $hashKey, $hashValue, int $ttl = 0): bool
3131
{
3232
$func = __FUNCTION__;
3333
$params = func_get_args();
@@ -60,7 +60,7 @@ protected static function _HSet(string $key, string|int $hashKey, mixed $hashVal
6060
* @param int $ttl
6161
* @return bool|int|float
6262
*/
63-
protected static function _HIncr(string $key, string|int $hashKey, int|float $hashValue = 1, int $ttl = 0): bool|int|float
63+
protected static function _HIncr(string $key, $hashKey, $hashValue = 1, int $ttl = 0)
6464
{
6565
$func = __FUNCTION__;
6666
$result = false;
@@ -101,7 +101,7 @@ protected static function _HIncr(string $key, string|int $hashKey, int|float $ha
101101
* @param int $ttl
102102
* @return bool|int|float
103103
*/
104-
protected static function _HDecr(string $key, string|int $hashKey, int|float $hashValue = 1, int $ttl = 0): bool|int|float
104+
protected static function _HDecr(string $key, $hashKey, $hashValue = 1, int $ttl = 0)
105105
{
106106
$func = __FUNCTION__;
107107
$result = false;
@@ -142,7 +142,7 @@ protected static function _HDecr(string $key, string|int $hashKey, int|float $ha
142142
* @param string|int ...$hashKey
143143
* @return bool
144144
*/
145-
protected static function _HDel(string $key, string|int ...$hashKey): bool
145+
protected static function _HDel(string $key, ...$hashKey): bool
146146
{
147147
$func = __FUNCTION__;
148148
$params = func_get_args();
@@ -172,7 +172,7 @@ protected static function _HDel(string $key, string|int ...$hashKey): bool
172172
* @param mixed|null $default
173173
* @return mixed
174174
*/
175-
protected static function _HGet(string $key, string|int $hashKey, mixed $default = null): mixed
175+
protected static function _HGet(string $key, $hashKey, $default = null)
176176
{
177177
$now = time();
178178
$hash = self::_Get($key, []);
@@ -227,7 +227,7 @@ protected static function _HRecycle(string $key): void
227227
* @param string|int ...$hashKey
228228
* @return array
229229
*/
230-
protected static function _HExists(string $key, string|int ...$hashKey): array
230+
protected static function _HExists(string $key, ...$hashKey): array
231231
{
232232
$hash = self::_Get($key, []);
233233
$result = [];
@@ -249,7 +249,7 @@ protected static function _HExists(string $key, string|int ...$hashKey): array
249249
* @param string|null $regex
250250
* @return array
251251
*/
252-
protected static function _HKeys(string $key, null|string $regex = null): array
252+
protected static function _HKeys(string $key, ?string $regex = null): array
253253
{
254254
$hash = self::_Get($key, []);
255255
$keys = [];

0 commit comments

Comments
 (0)