Giter Site home page Giter Site logo

laravel-redis's Introduction

laravel-redis

laravel-redis,本laravel包使用的是PHPRedis 需要开启Redis扩展才能使用,非predis

能提升代码执行效率,对应常见的string类型的get和set方法支持数组

配置laravel-ide-helper一起使用有代码提示

支持redis集群

安装

加载包

"link1st/laravel-redis": "dev-master"

composer require link1st/laravel-redis

在配置文件中添加 config/app.php

    'providers' => [
        /**
         * 添加供应商
         */
        link1st\RedisCache\RedisCacheServiceProvider::class,
    ],
    'aliases' => [
         /**
          * 添加别名
          */
        'RedisCache' => link1st\RedisCache\Facades\RedisCache::class,
    ],

生成配置文件

php artisan vendor:publish

设置参数 config/redis_cache.php

使用

  • 默认reids连接
// set 第二个参数可以为数组 第三个参数为ttl时间,默认不设置过期时间
\RedisCache::set('name',['name'=>'xiaoming']);

// get 返回一个数组
\RedisCache::get('name');

  • 切换redis连接
// - 需要提前在 redis_cache.php 配置redis连接
\RedisCache::openRedis('redis_config1')->get('name'));


$redis = \RedisCache::openRedis('redis_config1');
$redis->get('name');

laravel-redis's People

Contributors

link1st avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.