org.weborganic.bastille.cache.util
Class SoftCacheableString

java.lang.Object
  extended by org.weborganic.bastille.cache.util.SoftCacheableString
All Implemented Interfaces:
Serializable

public final class SoftCacheableString
extends Object
implements Serializable

A simple wrapper around a string optimised for caching.

Objects maintain a transient SoftReference to the string, ensuring that the string will only be removed if there is a risk of an OutOfMemoryError.

The object keeps a strong reference to a gzipped byte array, ensuring that the memory footprint is minimal when the soft reference is removed and the serialization process is optimal.

This class is useful for strings which are sufficiently large with a low entropy so that their gzipped representation will be significantly smaller than their string value.

See Also:
Serialized Form

Constructor Summary
SoftCacheableString(String data)
          Creates a new cached string.
 
Method Summary
 String get()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SoftCacheableString

public SoftCacheableString(String data)
Creates a new cached string.

Parameters:
data - the string to store
Throws:
NullPointerException - If the data is null
Method Detail

get

public String get()
Returns:
the string value.

toString

public String toString()
Overrides:
toString in class Object