微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

go-redis-client 特性示例Supported commandsTODO Redis 的 Go 客户端开发包

程序名称:go-redis-client 特性示例Supported commandsTODO

授权协议: MIT

操作系统: 跨平台

开发语言: Google Go

go-redis-client 特性示例Supported commandsTODO 介绍

go-redis-client 是国内团队灵雀云开发的 Go 语言的 Redis 客户端开发包,支持 Redis 单机和集群。

特性

  • 自动键前缀
  • 创建客户端实例时使用独立的参数对象
  • 内部使用 github.com/go-redis/redis 客户端,当前使用的是 gopkg.in/redis.v5
  • 客户端接口

示例

package main

import "redis" github.com/alauda/go-redis-client

func main() {
  // check options.go for more details
  opts := redis.RedisClientOptions{
    Type:     redis.Clientnormal,
    Hosts:    []string{"localhost:6379"},
    Password: "123456",
    Database: 0,
  }
  client := redis.NewRedisClient(opts)
  if err := client.Ping().Err(); err != nil {
    panic(err)
  }

  // Using cluster mode
  clusterOpts := redis.RedisClientOptions{
    Type:      redis.ClientCluster,
    Hosts:     []string{"localhost:7000","localhost:7001","localhost:7002"},
    Password:  "123456",
    Database:  0,
    // all keys with a prefix
    KeyPrefix: "my-app:",
  }
  clusterClient := redis.NewRedisClient(clusterOpts)
  if err := clusterClient.Ping().Err(); err != nil {
    panic(err)
  }
}

Supported commands

  • Ping
  • Incr
  • IncrBy
  • Decr
  • DecrBy
  • Expire
  • ExpireAt
  • Persist
  • PExpire
  • PExpireAt
  • PTTL
  • TTL
  • Exists
  • Get
  • GetBit
  • GetRange
  • GetSet
  • MGet
  • Dump
  • HExists
  • HGet
  • HGetAll
  • HIncrBy
  • HIncrByFloat
  • HKeys
  • HLen
  • HMGet
  • HMSet
  • HSet
  • HSetNX
  • HVals
  • LIndex
  • LInsert
  • LInsertAfter
  • LInsertBefore
  • LLen
  • LPop
  • LPush
  • LPushX
  • LRange
  • lRem
  • LSet
  • LTrim
  • RPop
  • RPopLPush
  • RPush
  • RPushX
  • Set
  • Append
  • Del
  • Unlink
  • SAdd
  • SCard
  • SDiff
  • SDiffStore
  • SInter
  • SInterStore
  • SIsMember
  • SMembers
  • SMove
  • SPop
  • SPopN
  • SRandMember
  • SRem
  • SUnion
  • SUnionStore
  • ZAdd
  • ZAddNX
  • ZAddXX
  • ZAddCh
  • ZaddNXCh
  • ZIncr
  • ZIncrNX
  • ZIncrXX
  • ZCard
  • ZCount
  • ZIncrBy
  • ZInterStore
  • ZRange
  • ZRangeWithscores
  • ZRangeByscore
  • ZRangeByLex
  • ZRangeByscoreWithscores
  • ZRank
  • ZRem
  • ZREmRangeByRank
  • ZRemRangeByscore
  • ZRemRangeByLex
  • ZRevRange
  • ZRevRangeWithscores
  • ZRevRangeByscore
  • ZRevRangeByLex
  • ZRevRangeByscoreWithscores
  • ZRevRank
  • Zscore
  • ZUnionStore
  • BLPop
  • BRPop
  • BRPopLPush
  • Type
  • Scan
  • SScan
  • ZScan
  • HScan
  • Publish
  • Subscribe

Todo

  • Update to redis.v6
  • Support RedisCluster Subscribe
  • Better support for godoc
  • Add docker-compose and example application
  • Add tests

go-redis-client 特性示例Supported commandsTODO 官网

https://github.com/alauda/go-redis-client

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐