GithubHelp home page GithubHelp logo

dtm-labs / rockscache Goto Github PK

View Code? Open in Web Editor NEW
527.0 20.0 72.0 85 KB

The First Redis Cache Library To Ensure Eventual Consistency And Strong Consistency With DB.

Home Page: http://d.dtm.pub/app/cache.html

License: BSD 3-Clause "New" or "Revised" License

Go 99.30% Shell 0.70%
cache consistency distributed redis

rockscache's Issues

rockscache能否支持go-redis v9版本

rockscache的go.mod中还引用v8版本的go-redis,但是我们项目已经使用v9的go-redis了,初始化rockscache的client会报错:
cannot use rdb (variable of type *"github.com/redis/go-redis/v9".Client) as "github.com/go-redis/redis/v8".UniversalClient value in argument to rockscache.NewClient: *"github.com/redis/go-redis/v9".Client does not implement "github.com/go-redis/redis/v8".UniversalClient (wrong type for method AddHook)
have AddHook("github.com/redis/go-redis/v9".Hook)
want AddHook("github.com/go-redis/redis/v8".Hook)

是否可以支持下v9版本的go-redis?

About the lockuntil is expired, and the data is also expired when data is not empty?

Why think that when the data is not empty, the lock expires and the data also expires?Why not use the TagAsDeleted function as the only trigger for cache updates?

I saw the code about default lockexpire time is 3s.Does it mean that an asynchronous update will be triggered every 3s, regardless of whether the data in the database is updated or not?

emo一下

延时锁的方式还是有很多人能想出来的,这个也用得上专利嘛。。。我很早前还在b站某缓存一致性介绍视频下评论过类似的办法呢。只是现在很多技术人员不愿意思考罢了,都是八股文害的。

可以添加一个是否缓存的条件么?

我想根据查询结果来判断是否缓存,请问可以添加一个是否缓存的条件么?
v, err := rc.Fetch("key1", 300 * time.Second, func()(string, bool,error) {
// fetch data from database or other sources
notneedcache=false
return "value1",notneedcache, nil
})

文中的demo会报错

func main() {
client := redis.NewClient(&redis.Options{
Network: "tcp",
Addr: "127.0.0.1:6379",
DB: 0,
})

rc := rockscache.NewClient(client, rockscache.NewDefaultOptions())
v, err := rc.Fetch("key2", 400, func() (string, error) {
	return "value2", nil
})
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(v)

}
key2的值为"aaa",获取时报下面的错误
ERR Error running script (call to f_a307994a908d94d53a2b772ddc6cf08109e0a828): @user_script:2: WRONGTYPE Operation against a key holding the wrong kind of value

A call to Fetch after TagAsDeleted returns an old value

client := redis.NewClient(&redis.Options{
		Addr:         "localhost:6379",
		Password:     "",
		DB:           0, // use default DB
	})
rc := rockscache.NewClient(client, rockscache.NewDefaultOptions())
rc.Fetch("test1", 60 * time.Second, func () (string, error) {
return "test1", nil
})
rc.TagAsDeleted("test1")
value, _ := rc.Fetch("test1", 60 * time.Second, func () (string, error) {
return "test2", nil
})
fmt.Println("value:", value)  // except return "test2", but got "test1"

[Enhancement] Options 支持配置统一缓存前缀

目前 options 中没有字段可以配置统一前缀,如果 Redis 服务器是多场景使用时,我必须要在每次设置缓存时,自定义 key 加统一前缀,如果可以设置统一前缀,可以统一管理,这对于使用更加友好

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.