Usage as Memory + Disk Cache #72
-
We are considering using FusionCache in a mobile application with the Is there any issue with this usage I’m not / I should be aware of? Is there a way to automatically or manually cleanup / delete all data which has expired more than some time span to keep the disk pressure to a minimum? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 7 replies
-
Hi @seyfeb and thanks for considering FusionCache!
Exactly! I collected the available I've never worked with it, but I'll take a look at their code to see if I see something smelly and come back to you.
Nope, that is the right approach 👍
I'm not sure I understood what you mean. If you mean directly with FusionCache then yes, just specify the If instead you mean directly on SQLite it depends on the implementation and the specific commands available. Hope this helps, will get back to you asap after I took a look at the package I mentioned. NOTE: I'll add that as of a couple of weeks ago you can even specify a different |
Beta Was this translation helpful? Give feedback.
-
I'm quickly looking at it right now, and in the So by default every 30 min it will physically remove the data from the db, but if you care about keeping the filesize as small as possible you may drop that value to something like Keep looking at its source, will update later... |
Beta Was this translation helpful? Give feedback.
-
I've finished looking at the code: at first it looks nicely done. A couple of notes:
All in all I would suggest you to play with it a little bit, maybe try different with different Let me know if you need something more, and if you like how it went! |
Beta Was this translation helpful? Give feedback.
-
Oh, one last thing: since you talked about cleaning up expired data in SQLite, I'd like to point something out about FusionCache internal behaviour which may be related, so you don't have surprises down the road. If you'll use the fail-safe mechanism in FusionCache keep in mind that the way it works is that the expiration you'll specify will be treated as a "logical expiration" (meaning you app will not see expired data anyway by way of checks done automatically) but the data itself will remain in the cache (so in this case also in SQLite) for more time, specifically based on the Practical example: if you cache something with a Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hey @jodydonetti , thanks a bunch! I did not begin to expect such an extensive and fast answer 😮
That's not what I was looking for. I was only concerned that over a long time (days), the disk cache might fill up the entire disk, if there is no cleanup mechanism involved - so every 30 minutes or even less is just fine and there are no concerns regarding the performance due to CPU cycles used for cleanup operations. Regarding the fail-safe mechanism, thanks for pointing out that objects need to be stored longer than the (logical) expiration time to be able to retrieve them in case of a failure. Although I must admit that this was obvious even to me ;) The SQLite implementation of the Finally, without having played around with your code, or even used it productively, it looks like a great and well thought-out library so I'm keen to use it. Keep up the good work and thanks for sharing!! |
Beta Was this translation helpful? Give feedback.
-
Hey @seyfeb , just FYI I've been inspired by your question and expanded the related docs to specifically cover disk cache 😉 Thanks! |
Beta Was this translation helpful? Give feedback.
Hi @seyfeb and thanks for considering FusionCache!
Exactly! I collected the available
IDistributedCache
implementations - at least the ones I've been able to find - in the related docs page.Here you can find the NeoSmart.Caching.Sqlite package: there's an official repo on GH (updated as recently as April of this year) and an introductory blogpost.
I've never worked with it, but I'll take a look at their code to se…