美文网首页
Redis用法

Redis用法

作者: 小蝎子tt | 来源:发表于2020-04-14 23:17 被阅读0次

    // 原生用法

            // $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 '没有数据';

            // }

    相关文章

      网友评论

          本文标题:Redis用法

          本文链接:https://www.haomeiwen.com/subject/oqefvhtx.html