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

[Suggestion] Ristretto Set may fail and it's the expected behavior #206

Open
Yiling-J opened this issue Apr 15, 2023 · 0 comments
Open

[Suggestion] Ristretto Set may fail and it's the expected behavior #206

Yiling-J opened this issue Apr 15, 2023 · 0 comments

Comments

@Yiling-J
Copy link

From Ristretto's Readme FAQ:

As for "shortcuts," the only thing Ristretto does that could be construed as one is dropping some Set calls

So both set and setTags may return false when using Ristretto. Maybe better to mention it in readme or do something in code.

And here is a simple parallel benchmark to demonstrate that:

func BenchmarkRistrettoSetParallel(b *testing.B) {
	ctx := context.Background()

	client, err := ristretto.NewCache(&ristretto.Config{
		NumCounters: 1000,
		MaxCost:     100,
		BufferItems: 64,
	})
	if err != nil {
		panic(err)
	}
	store := NewRistretto(client, nil)

	b.RunParallel(func(pb *testing.PB) {
		i := 0
		for pb.Next() {
			key := fmt.Sprintf("test-%d", i)
			value := []byte(fmt.Sprintf("value-%d", i))
			err := store.Set(ctx, key, value, lib_store.WithTags([]string{fmt.Sprintf("tag-%d", i)}))
			if err != nil {
				fmt.Print("x")
			}
			i++
		}
	})
}

you'll see some "x" when running it

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

1 participant