Redis用法

2020-04-14  本文已影响0人  小蝎子tt

// 原生用法

        // $redis=new \Redis();

        // $redis->connect(Config("REDIS_HOST"),Config("REDIS_PORT"));

        // $redis->SET('red',$to);

        // var_dump($redis->get('red'));

        //大神用法

        // $redis = RedisHash::instance();

        // $redis->setHashKey("to")->set($to);

        // dump($redis->setHashKey("to")->setKey(1)->get());

        // exit;

        // 手册用法

        // Cache::store('redis')->set('tt',$to);

        // $tt = Cache::get('tt');

        // dump($tt);

        // exit;

        //第三方用法

        // $options = [

        //     // 缓存类型为File

        //     'type' => 'redis',

        //     // 缓存有效期为永久有效

        //     'expire' => 7200,

        //     //缓存前缀

        //     'prefix' => ''

        // ];

        // $type1 = Db::name('uav_user')->where('uav_user_id',1)->select();

        // dump($type1);

        // exit;

        // $redis = Cache::connect($options);

        // //设置redis

        // $redis->set('type',$type1,20);

        // //获取redis

        // $type = $redis->get('type');

        // if($type)

        // {

        //     dump($type);

        //     return '有数据';

        // }

        // else

        // {

        //     dump($type);

        //     return '没有数据';

        // }

上一篇下一篇

猜你喜欢

热点阅读