PHP code example of jolalau / webman-redis

1. Go to this page and download the library: Download jolalau/webman-redis library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jolalau / webman-redis example snippets


composer 

use jolalau\WebManRedis\Redis;
use support\Request;

class Index
{
    public function test(Request $request)
    {
        $name = 'test_key';
        Redis::set($name, rand());
        return response(Redis::get($name));
    }
   
}

Redis::set('name', 'data'); // 永久有效
Redis::set('name', 'data', 600); // 有效期10分钟

Redis::get('name');
Redis::get('name', 'default');

if (Redis::has('name')) {
    //
}

Redis::delete('name');

Redis::clear();

为了区分默认的 redis.php 配置文件,故此改为 cache.php

config/cache.php