-
Notifications
You must be signed in to change notification settings - Fork 54
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
Cache Serialization serializes empty contents #90
Comments
I don't think Guava datatype module has explicit support for But assuming handling was added, typically cache types would be considered transient in the sense that only an empty instance would be serialized/read. Would you expect fully contents to be serialized/deserialized back? |
I see, saw what i'm seeing with Guava 30.1.1 is expected, right?
Yeap :) It would be very desirable to have a possibility to serialize these caches easily. Maybe i can sketch my use case a little: We have system connected to industrial machinery. Connected means we are also on the power supply of said machinery. These kinds of machines are simply switched off, so basically there is no real shutdown happening, we are just "gone" at one point. The intention right now is to send several small packets over the network to some server, but in case the server is not reachable for a moment, this stuff needs to be cached. Here enters guava cache. Easy to use, fast, easy to configure eviction policy, fits perfectly. Only part missing is that i need to make it persistent so i can restore that cache when we get turned on again. The persistence doesn't have to 100% perfect, that's why i was aiming to just serialize it into JSON and save it with the other stuff we already save for this type of getting shutdown. |
Ok, so yes; 21.0 fails to serialize since there are no properties found. 30.x is interesting since API itself is not different, but I am guessing As to supporting First of all: supporting serialization would be relatively easy:
However trying to support deserialization would be much more work:
I probably won't have time to work on this, except if it made sense to support "serialize as empty Object" which seems like a small step that might be useful -- and if so, perhaps counterpart on deserialization side. |
@wlfbck Instead of directly serializing/deserializing So something like:
(or, if you prefer, just a logical property with The idea here being that the hard part of serializing/deserializing entries is fully implemented by JDK Map / Jackson Map[De]Serializer -- and adding converters between that and Cache is simple enough at Java level. |
Added |
Might be simple enough to implement, marking as "good first issue" |
I'm trying to serialize a Guava Cache<String,String>, so nothing fancy. But this seems to either fail (using default guava version 21.0) with an InvalidDefinitionException or return
{}
(using guava 30.1.1-jre).Here's my minimal example, i hope i'm just stupid and missing something here:
My pom is minimal:
The text was updated successfully, but these errors were encountered: