Alexey Mayshev

Results 61 comments of Alexey Mayshev

It may be worth stopping returning bool in case of rejections. Then the API will become a little simpler. Still, otter guarantees that it can reject an item only because...

> I'd vote for changing terms from cost to weight for clarity It doesn't really matter to me here. It can be replaced with weight. > TTL is pretty well...

> They shouldn't be. Great, then this simplifies the situation a bit. ```java .expireAfterCreate(Duration.ofMinutes(5)) .expireAfterCreate((K key, V value) -> duration) ``` There is a small problem. There is no method...

Yeah, LoadingCache is really complicated. ```go type LoadingCache[K comparable, V any] interface { ... Get(ctx context.Context, key K) (V, error) BulkGet(ctx context.Context, keys []K) (map[K]V, error) // extension? Extension() LoadingExtension[K,...

The main problem is that `context.Context` is often used for the following things: 1. Timeout 2. Storage of various meta-information. Fields for logging and tracing, etc. Since it changes from...

To be honest, I didn't really understand :(. Why do I need to specify the loader every time I use the method? ```go type ( LoaderFunc[K comparable, V any] func(ctx...

Also, if we use `Get` and `Load` in the same type, it may be better to use a more common `Option` when creating a cache instead of a builder. The...

> In terms of the API SetIfAbsent(key K, value V) (V, bool), I think users would only expect the following two return cases: @rueian Yes, it seems like a good...

## About LoadingCache I've been thinking about `LoadingCache` for a long time and here's a little observation. ```go type LoadingCache[K comparable, V any] interface { ... Get(ctx context.Context, key K)...

In the case of `LoadingCache`, I'm still leaning towards something like this. ```go cache, err := otter.NewBuilder[int, int](). MaximumSize(1000). ExpireAfterWrite(time.Hour). CollectStats(). Loader(func(ctx context.Context, key K) (V, error) { ... })....