File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public function __construct(array $config = [])
2020 $ this ->score = 0 ;
2121 $ this ->hashKey = '' ;
2222 $ this ->expire = -1 ;
23-
23+
2424 $ options = [
2525 'parameters ' => [
2626 'password ' => $ config ['password ' ] ?? getenv ('REDIS_PASSWORD ' ) ?: '' ,
@@ -70,17 +70,17 @@ public function score(int $score): static
7070 }
7171
7272 /**
73- * 设置hash的key
74- *
73+ * 设置hash的key.
74+ *
7575 * @return $this
7676 */
7777 public function hashKey (string $ key ): static
7878 {
7979 $ this ->hashKey = $ key ;
80-
80+
8181 return $ this ;
8282 }
83-
83+
8484 /**
8585 * 设置过期时间.
8686 *
@@ -117,6 +117,7 @@ public function remember(string $key, callable $callback): mixed
117117 // 没有匹配写入cache
118118 $ return = $ callback ();
119119 $ this ->client ->zadd ($ key , $ this ->score , $ return );
120+
120121 return $ return ;
121122 },
122123 'put ' => function ($ value ) use ($ key ): void {
@@ -129,16 +130,17 @@ public function remember(string $key, callable $callback): mixed
129130 if ($ hash ) {
130131 return $ hash ;
131132 }
132-
133+
133134 // 没有匹配写入cache
134135 $ return = $ callback ();
135136 $ this ->client ->hset ($ key , $ this ->hashKey , $ return );
137+
136138 return $ return ;
137139 },
138140 'put ' => function ($ value ) use ($ key ) {
139141 $ this ->client ->hset ($ key , $ this ->hashKey , $ value );
140- }
141- ]
142+ },
143+ ],
142144 ];
143145
144146 $ getType = (string ) $ this ->client ->type ($ key );
Original file line number Diff line number Diff line change 77 ->expire (3600 )
88 ->remember ('test_zset ' , function () {
99 return json_encode ([
10- 'name ' => 'test101 '
10+ 'name ' => 'test101 ' ,
1111 ]);
1212 });
1313
2323 });
2424
2525 expect ($ response )->toEqual ('jqw4iej6uj48dw8 ' );
26- });
26+ });
You can’t perform that action at this time.
0 commit comments