Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A call to Fetch after TagAsDeleted returns an old value #12

Open
hoslo opened this issue Feb 22, 2023 · 4 comments
Open

A call to Fetch after TagAsDeleted returns an old value #12

hoslo opened this issue Feb 22, 2023 · 4 comments

Comments

@hoslo
Copy link

hoslo commented Feb 22, 2023

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"
@Wanghongw
Copy link

you need set StrongConsistency to true,like this:
rc.Options.StrongConsistency = true

@Wanghongw
Copy link

client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0, // use default DB
})
rc := rockscache.NewClient(client, rockscache.NewDefaultOptions())
// enable strongConsistency
rc.Options.StrongConsistency = true
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)

@hoslo
Copy link
Author

hoslo commented Feb 24, 2023

I think strongConsistency should default to true, otherwise my above result would look like something was wrong
@Wanghongw

@yedf2
Copy link
Contributor

yedf2 commented Feb 24, 2023

For most cache system, they are eventual consistency, not strong consistency.

In most cases, performance is the most important

Performance of strong consistency is lower than eventual consistency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants