You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now otter uses an api very similar to other go cache libraries, but unfortunately it is not particularly beautiful and extensible.
For example, now we have Set(key, value) and SetWithTTL(key, value, ttl) functions, but if we want to add SetIfAbsent(key, value) function, we also need SetIfAbsentWithTTL(key, value, ttl) function, which doesn't look nice anymore. Especially since when we create the cache in the builder we already know its further behavior and whether it will need ttl or not.
We would like to create a cache with a clean api and with the functions it needs using parameters in the builder. This will allow to provide such api as Set(key, value, ttl) and SetIfAbsent(key, value, ttl). Also, since in most cases ttl is the same for all entries in the cache, we don't need to pass it every time at all, further simplifying the api. This will also allow us to use optimizations for the expiration policy, since with the same ttl we only need to maintain a simple fifo queue of items and check their expiration one by one.
Acceptance criteria
A more advanced version of the builder has been implemented
Otter provides simpler api contracts
Implementation tests are written
The text was updated successfully, but these errors were encountered:
Clarification and motivation
Now otter uses an api very similar to other go cache libraries, but unfortunately it is not particularly beautiful and extensible.
For example, now we have
Set(key, value)
andSetWithTTL(key, value, ttl)
functions, but if we want to addSetIfAbsent(key, value)
function, we also needSetIfAbsentWithTTL(key, value, ttl)
function, which doesn't look nice anymore. Especially since when we create the cache in the builder we already know its further behavior and whether it will need ttl or not.We would like to create a cache with a clean api and with the functions it needs using parameters in the builder. This will allow to provide such api as
Set(key, value, ttl)
andSetIfAbsent(key, value, ttl)
. Also, since in most cases ttl is the same for all entries in the cache, we don't need to pass it every time at all, further simplifying the api. This will also allow us to use optimizations for the expiration policy, since with the same ttl we only need to maintain a simple fifo queue of items and check their expiration one by one.Acceptance criteria
The text was updated successfully, but these errors were encountered: