Comments (4)
Hey @ahovgaard!!
Thanks for spotting this issue and for the very detailed information. I know the references are not being removed on the evict decorator (just the given key but not its references), but you're right, it is an issue when a referencing key is updated, like you said, we end up with dangling keys in the cache, which I agree is not desirable. Let me look into it, and will try to come back with a solution soon.
from nebulex.
Deleting references during GC or backtracking them can be a solution
from nebulex.
I've been thinking about this and the best way to address it, but there is no quick fix, and any solution has pros and cons. So, let me break down the problem and address it incrementally.
-
The dangling keys. IMHO, I wouldn't consider this critical because there are some ways to handle it (will explain later). I agree that is not ideal, but providing a solution like backtracking the key references may bring also downsides as well in terms of memory and performance. So, I'd like to explore other alternatives I have in mind, but that will be for Nebulex v3; which is the highest priority now. In the meantime, to address this, there are a few things we can do. The first one (and perhaps the simplest one), is using the
:ttl
option. Another alternative, and the one I recommend and use myself, is having a separate cache for keeping the references only, a local cache with the local adapter for instance. This way, one could provide a different eviction or GC configuration, to run the GC more often and keep the references cache clean. -
Inconsistencies due to a dangling key (I'm talking about this:
In step 7, a new record is written to the DB (say from another machine running the app) using the old ID 123. When we read the record using that ID in step 9, the previously dangling reference from "[email protected]" now points to the new record with the mismatched email.
). This issue, on the contrary, I think is critical to fix, because we don't want to retrieve an inconsistent value. I've been working on something to address it. The idea is to leverage the match function when retrieving a reference to ensure the value is what we're expecting, and also be able to set a TTL for a reference (plus other stuff). However, it will be available in Nebulex v3; like I mentioned before, Nebulex v3 is the top priority now. I will keep you posted. -
Lastly, and perhaps the main problem, is the inaccurate and misleading documentation. I will fix the documentation based on what we have discussed here, explaining the issue and the possible immediate alternatives to address it.
Thank you very much for all the comments, suggestions, and so on, they're very well appreciated. I'll keep you posted about the progress.
from nebulex.
I've pushed a change fixing the docs about the cache_evict
decorator.
Also, as mentioned before, the inconsistency issue will be addressed on Nebulex v3 (https://github.com/cabol/nebulex/blob/v3.0.0-dev/lib/nebulex/caching/decorators.ex#L742-L805).
from nebulex.
Related Issues (20)
- Docs on Migrating to v2 from Nebulex.Adapters.Dist.Cluster HOT 5
- `Nebulex.Cache` callbacks mention "Shared Options" section that do not exist
- Support for functions that can set TTL in Decorator similar to Match HOT 9
- Where to use load/2, dump/2 HOT 4
- random :erpc, :timeout with partitioned get HOT 2
- Is there any way to get the size of the cache? HOT 4
- Seeing Nebulex.RPCError during deployments with partitioned adapter HOT 4
- Nebulex.RegistryLookupError HOT 9
- Ambiguity regarding ttl and gc_interval relation. HOT 4
- Replicated adapter syncing during rolling deployment HOT 5
- Bug on Local adapter when using `delete_all` and keys are nested tuples: not a valid match specification HOT 3
- is allocated_memory param global on per node when using Nebulex.Adapters.Partitioned with :shards HOT 2
- Regression on decorated functions and Elixir 1.16 HOT 3
- Empty arguments list passed to `generate/3` in Elixir 1.16 HOT 3
- `Multilevel` inclusive cache doesn't duplicate entries backwards on `get_all/2` HOT 3
- Fix compatibility with Elixir 1.15 and 1.16 HOT 3
- Support cache refreshing in the background HOT 1
- Having a cache per user ID... HOT 4
- 2.6.2 is missing from tags and releases on github HOT 1
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 nebulex.