Skip to content

Commit e63ee2b

Browse files
committed
Redis缓存使用示例
1 parent 54ed537 commit e63ee2b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tasks/Cache.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ public static function knows()
152152
}
153153
}
154154

155+
// 查看待缓存的已考知识点数据
156+
dump(Cache::knows());
157+
155158
// 缓存统计结果到 redis
156159
$client = new Predis\Client('tcp://127.0.0.1:6379');
157160
$client->set('phpems:questions', json_encode(Cache::questions()));
@@ -161,8 +164,9 @@ public static function knows()
161164
/* 在控制器中可以直接读取缓存并在模板中使用
162165
$client = new Predis\Client('tcp://127.0.0.1:6379');
163166
$questions = $client->get('phpems:questions');
164-
$questions = json_decode($questions,true);
167+
$questions = json_decode($questions, true);
168+
$knows = $client->get('phpems:knows');
169+
$knows = json_decode($knows, true);
165170
// $this->tpl->assign('questions', $questions);
166-
dd($questions);
167-
*/
168-
171+
dd($knows);
172+
*/

0 commit comments

Comments
 (0)