ristretto icon indicating copy to clipboard operation
ristretto copied to clipboard

[FEATURE]: Support for Type Parameters, aka, generics

Open paivagustavo opened this issue 3 years ago • 5 comments

Have you tried Ristretto before this proposal? and did not find anything similar?

No response

What you wanted to do.

I would like to be able to use the ristretto cache using type parameters to avoid conversions to/from interface{}. This both makes the code more performant and also cleaner to use.

What you actually did.

No response

Why wasn't it great, with examples.

No response

Additional information.

I've done an experiment migrating ristretto to Generics, It does seems to have positive impact on performance as well as we can see on some benchmarks added:

benchstat
name                            old time/op    new time/op    delta
CacheSet-8                        26.8ns ±15%    19.4ns ± 6%   -27.36%  (p=0.000 n=10+10)
ConcurrentCacheSetNeverEvict-8    80.1ns ±10%    78.4ns ±24%      ~     (p=0.661 n=9+10)

name                            old speed      new speed      delta
CacheSet-8                      37.5MB/s ±14%  51.5MB/s ± 6%   +37.18%  (p=0.000 n=10+10)

name                            old alloc/op   new alloc/op   delta
CacheSet-8                          113B ± 5%       79B ± 5%   -30.38%  (p=0.000 n=10+10)
ConcurrentCacheSetNeverEvict-8      105B ± 0%       88B ± 0%   -16.19%  (p=0.001 n=7+7)

name                            old allocs/op  new allocs/op  delta
CacheSet-8                          1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
ConcurrentCacheSetNeverEvict-8      3.00 ± 0%      1.00 ± 0%   -66.67%  (p=0.000 n=10+10)

I'm willing to submit these changes (and some other improvements) if Ristretto is willing to add support to Type Parameters.

paivagustavo avatar Nov 28 '22 22:11 paivagustavo

Or you can try my high hit ratio & good perofrmance generic cache package: https://github.com/Yiling-J/theine-go

Yiling-J avatar Apr 21 '23 13:04 Yiling-J

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.

github-actions[bot] avatar Jul 18 '24 14:07 github-actions[bot]

active

trim21 avatar Jul 18 '24 14:07 trim21

looks like this has been implemented https://github.com/dgraph-io/ristretto/pull/371

trim21 avatar Jul 24 '24 15:07 trim21

It looks like this fix was landed on Jan 16 (6+ months ago). Should we be expecting a new release anytime soon?

clayne11 avatar Jul 30 '24 17:07 clayne11