Git Product home page Git Product logo

lua-redis-cluster's Introduction

Name

纯lua实现的openresty上使用的redis集群实现, 依赖春哥的lua-resty-redis(https://github.com/openresty/lua-resty-redis) 代码逻辑基本上是redis的C实现照搬过来的,增加了些个人需要的功能,是长连接的. redis命令都支持的,只是维护槽分配的节点,然后用metatable把所有命令执行都交给春哥的lua-resty-redis执行. 发现春哥修改过redis.lua而我从未更新过,不知道区别在那里!

但是这个库是本公司生产在使用的,目前没发现什么问题.剩下的看你们了^_^

Methods

new

local redis_cluster = require "resty.redis_cluster"
local cluster_id = "redis_cluster"
local startup_nodes = { {"10.10.10.1", 10101},{"10.10.10.2", 10201},{"10.10.10.3", 10301}}
local opt = { 
	    timeout = 1000,--执行超时时间
	    keepalive_size = 50,--长连接数量
    keepalive_duration = 60000 --长连接保持时间
    }
  
local rc = redis_cluster:new(cluster_id, startup_nodes, opt)
local res,err=rc:set("xuzz",1)
ngx.log(ngx.ERR,"res=",tostring(res),err)
local res,err=rc:get("xuzz")
ngx.log(ngx.ERR,"res=",tostring(res),err)

cluster_dels

syntax: tres = rc:cluster_dels(regkey)

集群执行的删除匹配键值,返回每个集群节点中删除的结果,是一个table. 原理为单独连接集群每个节点用eval执行一段lua脚本批量删除匹配的key

cluster_status

syntax: tres = rc:cluster_status(bmaster?)

获得集群每个节点的状态,返回结果自己实验吧....哎呀我太懒了! 貌似这个命令有修改春哥的redis.lua这个坑了...只好你们自己实验出我修改了的redis.lua和春哥到底有什么不一样了...

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.