Categorygithub.com/Golang-Tools/redishelper
modulepackage
0.0.8
Repository: https://github.com/golang-tools/redishelper.git
Documentation: pkg.go.dev

# README

redishelper

github.com/go-redis/redis/v8的帮助程序

特性

  • 提供一个未设置被代理对象的默认代理对象Proxy
  • 可以代理Client,ClusterClient,FailoverClusterClient
  • 设置被代理对象时可以串行或者并行的执行注册的回调函数,回调函数只能在未设置被代理客户端时注册
  • 代理对象一旦被设置则无法替换
  • 封装了一些常用的工具
    • github.com/Golang-Tools/redishelper/bitmap封装了分布式位图,可以用于相对低空间占用的去重并且满足全部集合操作满足CanBeSetCanBeClientKey接口
    • github.com/Golang-Tools/redishelper/broker封装了redis支持的3种可以用作中间人的数据结构(queue,stream,pubsub),统一按生产者(CanBeProducerCanBeClientKey接口)消费者(CanBeConsumerCanBeClientKeyBatch接口)模式进行了封装
    • github.com/Golang-Tools/redishelper/cache封装了分布式缓存,支持使用分布式锁和分布式限制器控制缓存的执行策略,同时支持自动更新同步缓存内容,满足CanBeClientKey接口
    • github.com/Golang-Tools/redishelper/counter对象封装了分布式累加器,它也可以用于作为分布式系统的id生成器,满足接口CanBeCounterCanBeClientKey
    • github.com/Golang-Tools/redishelper/hypercount用于为大规模数据做去重计数和一部分集合操作,满足CanBeDisctinctCounterCanBeClientKey接口
    • github.com/Golang-Tools/redishelper/limiter限制器,用于限流和缓存防击穿等,满足接口CanBeLimiter
    • github.com/Golang-Tools/redishelper/lock分布式锁,用于避免分布式系统中的资源争抢,满足接口CanlockCanBeClientKey
    • github.com/Golang-Tools/redishelper/namespace用于构造命名空间的辅助工具
    • github.com/Golang-Tools/redishelper/proxy用于给github.com/go-redis/redis/v8中的客户端对象提供代理,满足接口redis.UniversalClient
    • github.com/Golang-Tools/redishelper/randomkey用于生成随机的key
    • github.com/Golang-Tools/redishelper/ranker排序工具封装,满足接口CanBeClientKey
    • github.com/Golang-Tools/redishelper/scanfinder封装了使用scan遍历全局keys的方法

# Packages

Package bitmap bitmap操作支持bitmap可以用于分布式去重bitmap实现了一般set的常用接口(Add,Remove,Contained,Len,ToArray).
No description provided by the author
Package cache 缓存对象更新缓存往往是竞争更新,因此需要使用分布式锁避免重复计算,同时等待更新完成后再取数据.
Package key redis的key包装.
No description provided by the author
No description provided by the author
No description provided by the author
Package hypercount 面向对象的计数估计类型HyperCount 用于粗略统计大量数据去重后的个数,一般用在日活计算.
Package keyspace_notifications对象.
Package limiter 限制器可以用于防止短时间内大量请求同时处理,比如缓存防击穿,防爬虫等.
Package lock 分布式锁实现分布式锁需要有客户端信息,只可以获得锁的客户端自己解锁或者等待锁自己过期当未能获得锁需要等待锁释放时可以通过wait接口实现.
No description provided by the author
No description provided by the author
Package randomkey 随机生成一个key使用sony实现的snowflake算法默认的设置为 StartTime: time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC),MachineID则会默认尝试使用本机的第一张网卡的mac地址最后1位,如果获取不到则会使用默认值0.
Package ranker 排序器类型ranker可以用于分布式排序操作即多个worker分别计算更新一部分元素的权重,业务端则只负责读取结果.
Package scanfinder 使用scan遍历查询的工具.

# Interfaces

No description provided by the author
No description provided by the author
CanBeConsumer 消费者对象的接口.
CanBeCount 可以被计数.
CanBeCounter 计数器接口.
No description provided by the author
CanBeGenerator 生成器的接口.
CanBeLimiter 限制器接口.
CanBeProducer 生产者对象的接口.
CanBeSet 可以被看作时Set的结构对象.
No description provided by the author
Canlock 锁对象的接口.