TestRedis.php 586 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace app\api\controller\v1;
  3. use think\Cache;
  4. class TestRedis
  5. {
  6. public function index()
  7. {
  8. $token = request()->param("token", null);
  9. if (!$token) {
  10. return json(["code" => 0, "message" => "token 不存在", "data" => null]);
  11. }
  12. if(Cache::store('default')->set("test_1989_name",$token,30)){
  13. echo Cache::store('default')->get("test_1989_name");
  14. exit;
  15. }
  16. echo "存取失败";exit;
  17. $token_value = Cache::store("default")->get($token);
  18. dump($token_value);
  19. die;
  20. }
  21. }