Comments (13)
Coming back to this;
I have a plan to implement this with a hook, but it won't work on a distributed scale (at least I don't think so). I'm going to investigate a way around this in future, perhaps by splitting out the remote caches into their own project.
from cachex.
@emerleite I've been considering this for a while, but I don't know an efficient way to trim the size, and on what grounds.
The most obvious is LRU, but that requires a sorted table in order to easily determine use time. Any ideas? Perhaps LFU should also be an option... that seems to make the most sense in context.
In the meantime, just set TTLs on your keys - that should be an easy workaround.
from cachex.
Further thinking on this makes me feel that we can implement LRU with a hook. There will naturally be overhead to this, but it can be toggled on/off if you have a clever enough eviction policy. I just need to work out some of the QLC magic behind it.
from cachex.
I set the TTL, but with high throughput, I'm not sure if I'll reach the limit anyway.
from cachex.
@zackehh I guess LFU could be better, but we could have a simple option to just rotate, regardless of the policy.
from cachex.
I found this project. Do you think we can go through the same aproach? - https://github.com/arago/lru_cache
from cachex.
@emerleite we can't, because using something like an Agent is a 6x slowdown on all reads against the throughput Cachex has today.
The reason I never added LRU before is simply because it would typically require a write on every read (like that Agent approach). I have an idea, but need to find some time to try an implementation.
from cachex.
@zackehh makes sense. But how about just set a limit and remove the first inserted? It's just to not reach system limit.
from cachex.
@emerleite first inserted is possible, but arguably the things you put in a cache instantly and live the longest are also those which need to be cached the most.
from cachex.
@emerleite how would you imagine this working in the case where you have a distributed cache?
from cachex.
@zackehh not sure. It's true we have to figure out this.
from cachex.
@emerleite I opened a new issue in #55. I'm going to close this one but feel free to follow that issue instead.
from cachex.
Coll @zackehh ;)
from cachex.
Related Issues (20)
- [question][guidance] bulk increment with ttl HOT 3
- Using Cachex with Phoenix and iex HOT 4
- [Elixir 1.15] ** (MatchError) no match of right hand side value: {1, {:error, :no_cache}} HOT 3
- Cachex.fetch hangs and breaks my app HOT 13
- Cachex warmer breaks the application with "no match of right hand side value: {:error, :no_cache}" error HOT 11
- Possible bug in :cachex_notify event handling? HOT 1
- Using `ordered_set` type tables to back cache HOT 1
- qlc error - max limit cache eviction fails for no cwd write permissions HOT 3
- Consider upgrading provisions to support Warmers as well as Hooks HOT 1
- Warmer blocking should be enabled on cache, rather than individual warmers HOT 2
- Warmers should have names defined, rather than simply the module name
- The :transactional option should be renamed to :transactions
- Cachex.warm/2 should be able to flip between blocking vs. non-blocking
- Remove set and set_many from the public API
- Migrate from using jump hashing to libring
- Create an abstraction over cluster state and routing
- Improve documentation on distributed caches
- Fetch can allow multiple executions of `fallback` function HOT 5
- Drop support for Elixir < 1.7
- dialyxir error in cachex/hook.ex:171:pattern_match_cov HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cachex.