Reputation: 669
For Ehcache, are there any constraints on the value that needs to be put in to? Like key does the value also need to implement 'serializable'
Upvotes: 8
Views: 6633
Reputation: 669
Objects used in Ehcache only need to implement Serializable if you need to store the cache on disk or are using cache replication
So the implementing Serializable for the values is optional.
@Louis As soon as you use a disk tier, objects have to be represented as byte arrays to be stored on disk and in Java the only standard way of doing that is Serialization. well said
Upvotes: -1
Reputation: 14500
Ehcache puts constraints on key and value types at two different levels:
First one is the API, where Element.getKey
and Element.getValue
, both deprecated, return a Serialiazable
. But there are two alternative methods:
Element.getObjectKey
Element.getObjectValue
which are the recommended ones anyway, and thus there is no restriction in the end.
Serialization
.Serialization
.That later points are the two cases where your keys and values must implement Serializable
.
Upvotes: 12