Class ClientCache<K,V>

java.lang.Object
com.scaleout.client.caching.ClientCache<K,V>
Type Parameters:
K - the key type of the associate Cache
V - the value type of the associated Cache

public abstract class ClientCache<K,V> extends Object

The ClientCache stores ClientCacheEntry's to speed up read operations.

When an object is stored in the ScaleOut Cache and the ClientCacheOptions.DeepCopy or ClientCacheOptions.Reference are specified, that object is placed into a in-process ClientCache. When reading the object, a lightweight version check will determine if the object can be retrieved from the ClientCache avoiding the receiving of the object from the ScaleOut in-memory data grid and subsequent deserialization of the object.

The implementation of the ClientCache is a weighted, thread-safe HashMap. The weighted size of the ClientCache is defined by the CacheBuilder.clientCacheSize(int). ClientCacheEntrys are evicted when the total entry weight (the summation of all ClientCacheEntryWeigher.evaluateEntryWeight(ClientCacheEntry)) is greater-than the value of the client cache weighted size.

By default, the ClientCache uses the default ClientCacheEntryWeigher which weighs a ClientCacheEntry based on the length of the serialized V object.

The CacheBuilder.clientCacheEntryWeigher(ClientCacheEntryWeigher) and CacheBuilder.clientCacheSize(int) can be used to customize per-entry weights and eviction.

  • Constructor Details

    • ClientCache

      public ClientCache()
      Default constructor.
  • Method Details

    • put

      public abstract void put(ClientCacheEntry<K,V> entry)
      Add an element to the client cache.
      Parameters:
      entry - the entry to add.
    • remove

      public abstract void remove(K key)
      Remove an entry from the client cache.
      Parameters:
      key - the key to remove.
    • get

      public abstract ClientCacheEntry<K,V> get(K key)
      Retrieve an entry from the client cache.
      Parameters:
      key - the key to the entry to retrieve.
      Returns:
      the entry or null.