Interface CacheSerializer<T>


  • public interface CacheSerializer<T>
    Serialize and deserialize cached data using ByteBuffer
    • Method Detail

      • serialize

        void serialize​(T value,
                       ByteBuffer buf)
        Serialize the specified type into the specified ByteBuffer instance.
        Parameters:
        value - non-null object that needs to be serialized
        buf - ByteBuffer into which serialization needs to happen.
      • deserialize

        T deserialize​(ByteBuffer buf)
        Deserialize from the specified DataInput instance.

        Implementations of this method should never return null. Although there might be no explicit runtime checks, a violation would break the contract of several API methods in OHCache. For example users of OHCache.get(Object) might not be able to distinguish between a non-existing entry or the "value" null. Instead, consider returning a singleton replacement object.

        Parameters:
        buf - ByteBuffer from which deserialization needs to happen.
        Returns:
        the type that was deserialized. Must not return null.
      • serializedSize

        int serializedSize​(T value)
        Calculate the number of bytes that will be produced by serialize(Object, java.nio.ByteBuffer) for given object t.
        Parameters:
        value - non-null object to calculate serialized size for
        Returns:
        serialized size of t