com.caucho.server.distcache
Class DistCacheEntry

java.lang.Object
  extended by com.caucho.server.distcache.DistCacheEntry
All Implemented Interfaces:
ExtCacheEntry, Cache.Entry

public class DistCacheEntry
extends java.lang.Object
implements ExtCacheEntry

An entry in the cache map


Constructor Summary
DistCacheEntry(CacheStoreManager engine, java.lang.Object key, HashKey keyHash, TriadOwner owner)
           
DistCacheEntry(CacheStoreManager engine, java.lang.Object key, HashKey keyHash, TriadOwner owner, CacheConfig config)
           
 
Method Summary
 void addLoadCount()
           
 void clearLease()
           
 HashKey compareAndPut(HashKey testValue, java.lang.Object value, CacheConfig config)
          Sets the current value
 boolean compareAndPut(long version, HashKey value, long valueLength, CacheConfig config)
          Sets the current value
 boolean compareAndSet(MnodeEntry oldMnodeValue, MnodeEntry mnodeValue)
          Sets the current value.
 void finishReadUpdate()
          Completes an update of a cache item.
 java.lang.Object get(CacheConfig config)
          Returns the object for the given key, checking the backing if necessary.
 long getAccessedExpireTimeout()
          Returns the idle timeout
 java.lang.Object getAndPut(java.lang.Object value, CacheConfig config)
          Sets the current value
 HashKey getCacheHash()
          Returns the cacheHash
 long getCost()
           
 long getCreationTime()
           
 java.lang.Object getExact(CacheConfig config)
          Returns the object for the given key, checking the backing if necessary.
 long getExpirationTime()
           
 int getHits()
           
 java.lang.Object getKey()
          Returns the key for this entry in the Cache.
 HashKey getKeyHash()
          Returns the keyHash
 long getLastAccessedTime()
           
 long getLastModifiedTime()
          Returns the last update time.
 int getLeaseOwner()
          Returns the lease owner
 long getLeaseTimeout()
          Returns the lease timeout
 int getLoadCount()
          Returns the load count.
 MnodeEntry getMnodeEntry()
          Returns the value section of the entry.
 MnodeEntry getMnodeValue(CacheConfig config)
          Returns the object for the given key, checking the backing if necessary
 long getModifiedExpireTimeout()
          Returns the expire timeout.
 TriadOwner getOwner()
          Returns the owner
 boolean getStream(java.io.OutputStream os, CacheConfig config)
          Fills the value with a stream
 int getUserFlags()
           
 java.lang.Object getValue()
          Returns the value of the cache entry.
 HashKey getValueHash(java.lang.Object value, CacheConfig config)
           
 byte[] getValueHashArray()
           
 HashKey getValueHashKey()
          Returns the value key
 long getValueLength()
          Returns the value length
 long getVersion()
           
 boolean isExpired(long now)
          Returns true when the entry is expired.
 boolean isValid()
           
 boolean isValueNull()
          Returns true if the value is null.
 java.lang.Object peek()
          Peeks the current value without checking the backing store.
 ExtCacheEntry put(java.io.InputStream is, CacheConfig config, long accessedExpireTimeout, long modifiedExpireTimeout)
          Sets the value by an input stream
 ExtCacheEntry put(java.io.InputStream is, CacheConfig config, long accessedExpireTimeout, long modifiedExpireTimeout, int flags)
          Sets the value by an input stream
 void put(java.lang.Object value, CacheConfig config)
          Sets the current value
 boolean remove(CacheConfig config)
          Remove the value
 java.lang.Object setValue(java.lang.Object value)
           
 boolean startReadUpdate()
          Conditionally starts an update of a cache item, allowing only a single thread to update the data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistCacheEntry

public DistCacheEntry(CacheStoreManager engine,
                      java.lang.Object key,
                      HashKey keyHash,
                      TriadOwner owner)

DistCacheEntry

public DistCacheEntry(CacheStoreManager engine,
                      java.lang.Object key,
                      HashKey keyHash,
                      TriadOwner owner,
                      CacheConfig config)
Method Detail

getKey

public final java.lang.Object getKey()
Returns the key for this entry in the Cache.

Specified by:
getKey in interface Cache.Entry

getKeyHash

public final HashKey getKeyHash()
Returns the keyHash

Specified by:
getKeyHash in interface ExtCacheEntry

getValue

public java.lang.Object getValue()
Returns the value of the cache entry.

Specified by:
getValue in interface ExtCacheEntry
Specified by:
getValue in interface Cache.Entry

isValueNull

public boolean isValueNull()
Returns true if the value is null.

Specified by:
isValueNull in interface ExtCacheEntry

getCacheHash

public final HashKey getCacheHash()
Returns the cacheHash


getUserFlags

public final int getUserFlags()
Specified by:
getUserFlags in interface ExtCacheEntry

getOwner

public final TriadOwner getOwner()
Returns the owner


getMnodeEntry

public final MnodeEntry getMnodeEntry()
Returns the value section of the entry.


peek

public java.lang.Object peek()
Peeks the current value without checking the backing store.


get

public java.lang.Object get(CacheConfig config)
Returns the object for the given key, checking the backing if necessary. If it is not found, the optional cacheLoader is invoked, if present.


getExact

public java.lang.Object getExact(CacheConfig config)
Returns the object for the given key, checking the backing if necessary. If it is not found, the optional cacheLoader is invoked, if present.


getMnodeValue

public MnodeEntry getMnodeValue(CacheConfig config)
Returns the object for the given key, checking the backing if necessary


getStream

public boolean getStream(java.io.OutputStream os,
                         CacheConfig config)
                  throws java.io.IOException
Fills the value with a stream

Throws:
java.io.IOException

getValueHash

public HashKey getValueHash(java.lang.Object value,
                            CacheConfig config)

put

public void put(java.lang.Object value,
                CacheConfig config)
Sets the current value


put

public ExtCacheEntry put(java.io.InputStream is,
                         CacheConfig config,
                         long accessedExpireTimeout,
                         long modifiedExpireTimeout)
                  throws java.io.IOException
Sets the value by an input stream

Throws:
java.io.IOException

put

public ExtCacheEntry put(java.io.InputStream is,
                         CacheConfig config,
                         long accessedExpireTimeout,
                         long modifiedExpireTimeout,
                         int flags)
                  throws java.io.IOException
Sets the value by an input stream

Throws:
java.io.IOException

getAndPut

public java.lang.Object getAndPut(java.lang.Object value,
                                  CacheConfig config)
Sets the current value


compareAndPut

public HashKey compareAndPut(HashKey testValue,
                             java.lang.Object value,
                             CacheConfig config)
Sets the current value


compareAndPut

public boolean compareAndPut(long version,
                             HashKey value,
                             long valueLength,
                             CacheConfig config)
Sets the current value


remove

public boolean remove(CacheConfig config)
Remove the value


startReadUpdate

public final boolean startReadUpdate()
Conditionally starts an update of a cache item, allowing only a single thread to update the data.

Returns:
true if the thread is allowed to update

finishReadUpdate

public final void finishReadUpdate()
Completes an update of a cache item.


compareAndSet

public final boolean compareAndSet(MnodeEntry oldMnodeValue,
                                   MnodeEntry mnodeValue)
Sets the current value.


getValueHashKey

public HashKey getValueHashKey()
Description copied from interface: ExtCacheEntry
Returns the value key

Specified by:
getValueHashKey in interface ExtCacheEntry

getValueHashArray

public byte[] getValueHashArray()

getValueLength

public long getValueLength()
Description copied from interface: ExtCacheEntry
Returns the value length

Specified by:
getValueLength in interface ExtCacheEntry

getAccessedExpireTimeout

public long getAccessedExpireTimeout()
Description copied from interface: ExtCacheEntry
Returns the idle timeout

Specified by:
getAccessedExpireTimeout in interface ExtCacheEntry

getModifiedExpireTimeout

public long getModifiedExpireTimeout()
Description copied from interface: ExtCacheEntry
Returns the expire timeout.

Specified by:
getModifiedExpireTimeout in interface ExtCacheEntry

isExpired

public boolean isExpired(long now)
Description copied from interface: ExtCacheEntry
Returns true when the entry is expired.

Specified by:
isExpired in interface ExtCacheEntry

getLeaseTimeout

public long getLeaseTimeout()
Description copied from interface: ExtCacheEntry
Returns the lease timeout

Specified by:
getLeaseTimeout in interface ExtCacheEntry

getLeaseOwner

public int getLeaseOwner()
Description copied from interface: ExtCacheEntry
Returns the lease owner

Specified by:
getLeaseOwner in interface ExtCacheEntry

clearLease

public void clearLease()

getCost

public long getCost()

getCreationTime

public long getCreationTime()

getExpirationTime

public long getExpirationTime()

getHits

public int getHits()

getLastAccessedTime

public long getLastAccessedTime()
Specified by:
getLastAccessedTime in interface ExtCacheEntry
Returns:

getLastModifiedTime

public long getLastModifiedTime()
Description copied from interface: ExtCacheEntry
Returns the last update time.

Specified by:
getLastModifiedTime in interface ExtCacheEntry

getVersion

public long getVersion()
Specified by:
getVersion in interface ExtCacheEntry
Returns:

isValid

public boolean isValid()
Specified by:
isValid in interface ExtCacheEntry

setValue

public java.lang.Object setValue(java.lang.Object value)

addLoadCount

public void addLoadCount()

getLoadCount

public int getLoadCount()
Description copied from interface: ExtCacheEntry
Returns the load count.

Specified by:
getLoadCount in interface ExtCacheEntry

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object