-
-
Notifications
You must be signed in to change notification settings - Fork 74
Examples and documentation for storage and persistence #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It actually works (better read: "should work") with:
Ideally that is the minimum configuration to just store your objects in a file, if these are serializable. However, there is a big BUT: The code is not yet production ready. I have some heavy duty tests with lots of concurrency and see some issues. Those are related with some tough functions: clear() and the iterator().... I'll just opened #30 to track how we move on with the persistence support now. Some background for your understanding: The storage is designed to be a path additional to the read through with the CacheSource (in the git master there is also write through with a CacheWriter). So you can have a CacheSource, e.g. fetching the weather for a location from an external service, make the data persistent and keep half of it in the heap. I will keep this issue to provide some examples for the persistence configuration, either I paste some here directly or I do write up some unit tests. |
Thanks a lot for you prompt answer. Do you consider I will spend some time tomorrow with code from master and I can give you some feedback, if you wish. |
The funny thing is, after 16 years of doing caching, in our Java applications we never made use of a CacheWriter. Question: In case a fetch from the source is processing and an entry is written, what should happen:
Variant 1&2 implies that the CacheWriter may be called during an access of the cache source of the same key. Currently variant 3 should be how it works. Do really need the CacheWriter? Do you get external calls storing data or can do requests or generate the value by the key? If the latter is the case, you can put all the logic in the CacheSource only.
This is thread safe, no source call to the same key is made at one time. |
I'm really confused. I don't even understand the purpose of the concept of "storage" in the domain of cache2k My understanding of storage is that there's a layer of software responsible for managing all reads/writes of data from/to a physical persistent device (not on-heap memory!). But I guess my [pre-]concept of storage is wrong in the domain of cache2k. So, considering my understanding or more precisely: lack of understanding, I'd better stick to my current implementation, since there are not enough examples and documentation about how Besides, Answering your question: "Do you really need a CacheWriter?" ... well... it's an interface which exposes methods which I'm already using anyway (conceptually... not really the exact method signatures!). So, why should I reinvent the wheel? Also, my supposition (possibly a wrong supposition) is that |
Sorry for the confusion, your feedback is much appreciated. As promised, I will put together some examples. |
Examples are here now: I also went through the configuration and added some description of the options. The example works with master, but should do the same with the released version. That should shed some light on the whole thing and how everything is thought out. Questions? Thoughts? Suggestions? |
Hi Jens, thanks a lot for that :-) |
Please provide an example (possibly under cache2k-benchmark) which employs a cache backed by a file storage.
At the moment, I'm doing the file storage thing by hand.
I suspect that
PassingStorage
is meant to do what I'm doing by hand.This is my implementation:
https://gist.github.com/frgomes/f027f696299c624666f3
The text was updated successfully, but these errors were encountered: