All Projects → piaohao → Godis

piaohao / Godis

Licence: mit
redis client implement by golang, inspired by jedis.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Godis

Iodine
iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
Stars: ✭ 720 (+727.59%)
Mutual labels:  redis, redis-client
Redis Py Cluster
Python cluster client for the official redis cluster. Redis 3.0+.
Stars: ✭ 934 (+973.56%)
Mutual labels:  redis, redis-client
Redis Tui
A Redis Text-based UI client in CLI
Stars: ✭ 757 (+770.11%)
Mutual labels:  redis, redis-client
Stackexchange.redis
General purpose redis client
Stars: ✭ 4,986 (+5631.03%)
Mutual labels:  redis, redis-client
Ioredis
🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
Stars: ✭ 9,754 (+11111.49%)
Mutual labels:  redis, redis-client
Quick redis blog
QuickRedis is a free forever Redis Desktop manager. It supports direct connection, sentinel, and cluster mode, supports multiple languages, supports hundreds of millions of keys, and has an amazing UI. Supports both Windows, Mac OS X and Linux platform.
Stars: ✭ 594 (+582.76%)
Mutual labels:  redis, redis-client
Redix
Fast, pipelined, resilient Redis driver for Elixir. 🛍
Stars: ✭ 816 (+837.93%)
Mutual labels:  redis, redis-client
Stackexchange.redis.extensions
Stars: ✭ 419 (+381.61%)
Mutual labels:  redis, redis-client
Php Redis Implementation
Raw wrapper for real Redis fans.
Stars: ✭ 48 (-44.83%)
Mutual labels:  redis, redis-client
Cpp redis
C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform - NO LONGER MAINTAINED - Please check https://github.com/cpp-redis/cpp_redis
Stars: ✭ 855 (+882.76%)
Mutual labels:  redis, redis-client
Redis Admin
redis client tool,redis web client,redis web ui,spring-boot support
Stars: ✭ 436 (+401.15%)
Mutual labels:  redis, redis-client
Micropython Stm Lib
A collection of modules and examples for MicroPython running on an STM32F4DISCOVERY board
Stars: ✭ 64 (-26.44%)
Mutual labels:  redis, redis-client
Redis
Vapor provider for RediStack
Stars: ✭ 434 (+398.85%)
Mutual labels:  redis, redis-client
Redis Operator
Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Stars: ✭ 658 (+656.32%)
Mutual labels:  redis, redis-client
Redis Plus Plus
Redis client written in C++
Stars: ✭ 428 (+391.95%)
Mutual labels:  redis, redis-client
Hslcommunication
An industrial IoT underlying architecture framework, focusing on the underlying technical communications and cross-platform, cross-language communication functions, to achieve a variety of mainstream PLC data reading and writing, to achieve modbus of various protocols read and write, and so on, to support the rapid construction of industrial upper computer software, configuration software, SCADA software, factory mes system, To help enterprise Industry 4.0 take-off, to achieve intelligent manufacturing, smart factory goals. The main PLC contains Siemens, Mitsubishi, Omron, Panasonic, Modbus, AB-PLC, Redis
Stars: ✭ 816 (+837.93%)
Mutual labels:  redis, redis-client
Redis
Redis commands for Elixir
Stars: ✭ 357 (+310.34%)
Mutual labels:  redis, redis-client
Lettuce Core
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Stars: ✭ 4,319 (+4864.37%)
Mutual labels:  redis, redis-client
Perfect Redis
A Swift client for Redis.
Stars: ✭ 26 (-70.11%)
Mutual labels:  redis, redis-client
Goredis
redis client for golang
Stars: ✭ 59 (-32.18%)
Mutual labels:  redis, redis-client

godis

Go Doc Build Status Go Report codecov License

redis client implement by golang, refers to jedis.
this library implements most of redis command, include normal redis command, cluster command, sentinel command, pipeline command and transaction command.
if you've ever used jedis, then you can use godis easily, godis almost has the same method of jedis.
especially, godis implements distributed lock in single mode and cluster mode, godis's lock is much more faster than redisson, on my computer(i7,8core,32g), run 100,000 loop, use 8 threads, the business code is just count++, redisson need 18s-20s, while godis just need 7 second.
godis has done many test case to make sure it's stable.

I am glad you made any suggestions, and I will actively iterate over the project.

Features

  • cluster
  • pipeline
  • transaction
  • distributed lock
  • other feature under development

Installation

go get -u github.com/piaohao/godis

or use go.mod:

require github.com/piaohao/godis latest

Documentation

Quick Start

  1. basic example

    package main
    
    import (
        "github.com/piaohao/godis"
    )
    
    func main() {
        redis := godis.NewRedis(&godis.Option{
            Host: "localhost",
            Port: 6379,
            Db:   0,
        })
        defer redis.Close()
        redis.Set("godis", "1")
        arr, _ := redis.Get("godis")
        println(arr)
    }
    
  2. use pool

    package main
    
    import (
        "github.com/piaohao/godis"
    )
    
    func main() {
        option:=&godis.Option{
            Host: "localhost",
            Port: 6379,
            Db:   0,
        }
        pool := godis.NewPool(&godis.PoolConfig{}, option)
        redis, _ := pool.GetResource()
        defer redis.Close()
        redis.Set("godis", "1")
        arr, _ := redis.Get("godis")
        println(arr)
    }
    
  3. pubsub

    package main
    
    import (
        "github.com/piaohao/godis"
        "time"
    )
    
    func main() {
        option:=&godis.Option{
            Host: "localhost",
            Port: 6379,
            Db:   0,
        }
        pool := godis.NewPool(&godis.PoolConfig{}, option)
        go func() {
            redis, _ := pool.GetResource()
            defer redis.Close()
            pubsub := &godis.RedisPubSub{
                OnMessage: func(channel, message string) {
                    println(channel, message)
                },
                OnSubscribe: func(channel string, subscribedChannels int) {
                    println(channel, subscribedChannels)
                },
                OnPong: func(channel string) {
                    println("recieve pong")
                },
            }
            redis.Subscribe(pubsub, "godis")
        }()
        time.Sleep(1 * time.Second)
        {
            redis, _ := pool.GetResource()
            defer redis.Close()
            redis.Publish("godis", "godis pubsub")
            redis.Close()
        }
        time.Sleep(1 * time.Second)
    }
    
  4. cluster

    package main
    
    import (
        "github.com/piaohao/godis"
        "time"
    )
    
    func main() {
        cluster := godis.NewRedisCluster(&godis.ClusterOption{
            Nodes:             []string{"localhost:7000", "localhost:7001", "localhost:7002", "localhost:7003", "localhost:7004", "localhost:7005"},
            ConnectionTimeout: 0,
            SoTimeout:         0,
            MaxAttempts:       0,
            Password:          "",
            PoolConfig:        &godis.PoolConfig{},
        })
        cluster.Set("cluster", "godis cluster")
        reply, _ := cluster.Get("cluster")
        println(reply)
    }
    
  5. pipeline

    package main
    
    import (
        "github.com/piaohao/godis"
        "time"
    )
    
    func main() {
        option:=&godis.Option{
            Host: "localhost",
            Port: 6379,
            Db:   0,
        }
        pool := godis.NewPool(&godis.PoolConfig{}, option)
        redis, _ := pool.GetResource()
        defer redis.Close()
        p := redis.Pipelined()
        infoResp, _ := p.Info()
        timeResp, _ := p.Time()
        p.Sync()
        timeList, _ := timeResp.Get()
        println(timeList)
        info, _ := infoResp.Get()
        println(info)
    }
    
  6. transaction

    package main
    
    import (
        "github.com/piaohao/godis"
        "time"
    )
    
    func main() {
        option:=&godis.Option{
            Host: "localhost",
            Port: 6379,
            Db:   0,
        }
        pool := godis.NewPool(nil, option)
        redis, _ := pool.GetResource()
        defer redis.Close()
        p, _ := redis.Multi()
        infoResp, _ := p.Info()
        timeResp, _ := p.Time()
        p.Exec()
        timeList, _ := timeResp.Get()
        println(timeList)
        info, _ := infoResp.Get()
        println(info)
    }
    
  7. distribute lock

    • single redis
         package main
         
         import (
             "github.com/piaohao/godis"
             "time"
         )
         
         func main() {
             locker := godis.NewLocker(&godis.Option{
                   Host: "localhost",
                   Port: 6379,
                   Db:   0,
               }, &godis.LockOption{
                   Timeout: 5*time.Second,
               })
             lock, err := locker.TryLock("lock")
             if err == nil && lock!=nil {
                 //do something
                 locker.UnLock(lock)
             }
             
         }
      
    • redis cluster
         package main
         
         import (
             "github.com/piaohao/godis"
             "time"
         )
         
         func main() {
             locker := godis.NewClusterLocker(&godis.ClusterOption{
             	Nodes:             []string{"localhost:7000", "localhost:7001", "localhost:7002", "localhost:7003", "localhost:7004", "localhost:7005"},
                 ConnectionTimeout: 0,
                 SoTimeout:         0,
                 MaxAttempts:       0,
                 Password:          "",
                 PoolConfig:        &godis.PoolConfig{},
             },&godis.LockOption{
                 Timeout: 5*time.Second,
             })
             lock, err := locker.TryLock("lock")
             if err == nil && lock!=nil {
                 //do something
                 locker.UnLock(lock)
             }
         }
      

License

godis is licensed under the MIT License, 100% free and open-source, forever.

Thanks

Contact

[email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].