com.alachisoft.ncache.web.caching
Class CacheItem

java.lang.Object
  extended by com.alachisoft.ncache.web.caching.CacheItem

public class CacheItem
extends java.lang.Object

Class that represents a cached item including its dependencies, expiration and eviction information


Constructor Summary
CacheItem(java.lang.Object value)
          Constructor
 
Method Summary
 java.lang.Object Clone()
          If dependency or ItemUpdateCallbacks are used in this cacheItem then it is a shallow copy, else this clone method observes a deep clone
 java.util.Date getAbsoluteExpiration()
          The time at which the added object expires and is removed from the cache.
 AsyncItemAddedCallback getAsyncItemAddedCallback()
          An instance that, if provided, is called when an Asynchronous request for Add Operation completes.
 AsyncItemUpdatedCallback getAsyncItemUpdatedCallback()
          An instance that, if provided, is called when an Asynchronous request for Update Operation completes.
 CacheDependency getCacheDependency()
          The file or cache key dependencies for the item.
 CacheSyncDependency getCacheSyncDependency()
          The cache key dependencies for the item.
 java.lang.String getGroup()
          Group name, this caheItem is to be included in
 CacheItemRemovedCallback getItemRemoveCallback()
          An instance that, if provided, is called when an object is removed from the cache.
 CacheItemUpdatedCallback getItemUpdateCallback()
          An instance that, if provided, is called when an object is updated in the cache.
 NamedTagsDictionary getNamedTags()
           
 CacheItemPriority getPriority()
          The relative cost of the object, as expressed by the enumeration.
 boolean getResyncExpiredItems()
          Gets a value indicating whether the object when expired will cause a re-fetch of the object from the master datasource.
 java.lang.String getResyncProviderName()
           
 TimeSpan getSlidingExpiration()
          The interval between the time the added object was last accessed and when that object expires.
 java.lang.String getSubGroup()
          SubGroup name, this caheItem is to be included in
 Tag[] getTags()
          gets all tags this CacheItem is attached to
 java.lang.Object getValue()
          The payload for this item.
 CacheItemVersion getVersion()
          Item version of the object, used when getCachItem is used on Cache
 void setAbsoluteExpiration(java.util.Date absoluteExpiration)
          Sets the time at which the added object expires and is removed from the cache.
 void setAsyncItemAddedCallback(AsyncItemAddedCallback itemAddedCallback)
          An instance that, if provided, is called when an Asynchronous request for Add Operation completes.
 void setAsyncItemUpdatedCallback(AsyncItemUpdatedCallback itemUpdatedCallback)
          An instance that, if provided, is called when an Asynchronous request for Update Operation completes.
 void setCacheDependency(CacheDependency dependency)
           
 void setCacheSyncDependency(CacheSyncDependency syncDependency)
          The cache key dependencies for the item.
 void setGroup(java.lang.String group)
          The name of the group to associate with the cache item.
 void setItemRemoveCallback(CacheItemRemovedCallback itemRemoveCallback)
          An instance that, if provided, is called when an object is removed from the cache.
 void setItemUpdateCallback(CacheItemUpdatedCallback itemUpdateCallback)
          An instance that, if provided, is called when an object is updated in the cache.
 void setNamedTags(NamedTagsDictionary namedTags)
           
 void setPriority(CacheItemPriority priority)
           
 void setPriority(int p)
          Set priority using integer value
 void setResyncExpiredItems(boolean resync)
           
 void setResyncProviderName(java.lang.String resyncProviderName)
           
 void setSlidingExpiration(TimeSpan slidingExpiration)
           
 void setSubGroup(java.lang.String subGroup)
          The name of the sub-group within a group.
 void setTags(Tag[] tags)
          sets all tags this CacheItem is to be attached to
 void setValue(java.lang.Object value)
           
 void setVersion(CacheItemVersion version)
          Sets Item Version
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheItem

public CacheItem(java.lang.Object value)
Constructor

Parameters:
value - Actual object to be stored in cache
Method Detail

Clone

public java.lang.Object Clone()
If dependency or ItemUpdateCallbacks are used in this cacheItem then it is a shallow copy, else this clone method observes a deep clone

Returns:
CacheItem as an Object

getAbsoluteExpiration

public java.util.Date getAbsoluteExpiration()
The time at which the added object expires and is removed from the cache.

Returns:
The time at which the added object expires and is removed from the cache.

getAsyncItemAddedCallback

public AsyncItemAddedCallback getAsyncItemAddedCallback()
An instance that, if provided, is called when an Asynchronous request for Add Operation completes. You can use this to obtain the results of an 'AddAsync' operation.

Returns:
instance of the callback
See Also:
AsyncItemAddedCallback

getAsyncItemUpdatedCallback

public AsyncItemUpdatedCallback getAsyncItemUpdatedCallback()
An instance that, if provided, is called when an Asynchronous request for Update Operation completes. You can use this to obtain the results of an 'InsertAsync' operation.

Returns:
instance of the callback
See Also:
AsyncItemUpdatedCallback

getCacheDependency

public CacheDependency getCacheDependency()
The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this property contains a null reference.

Returns:
The CacheDependency of this Item.
See Also:
CacheDependency

getCacheSyncDependency

public CacheSyncDependency getCacheSyncDependency()
The cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this property contains a null reference.

Returns:
The CacheSyncDependency of this Item.
See Also:
CacheSyncDependency

getGroup

public java.lang.String getGroup()
Group name, this caheItem is to be included in

Returns:
Group Name

getItemRemoveCallback

public CacheItemRemovedCallback getItemRemoveCallback()
An instance that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their Objects are deleted from the cache.

Returns:
instance of the callback
See Also:
CacheItemRemovedCallback

getItemUpdateCallback

public CacheItemUpdatedCallback getItemUpdateCallback()
An instance that, if provided, is called when an object is updated in the cache. You can use this to notify applications when their objects are updated in the cache.

Returns:
instance of the callback
See Also:
CacheItemUpdatedCallback

getNamedTags

public NamedTagsDictionary getNamedTags()
Returns:
NamedTagsDictionary associated with CacheItem

getPriority

public CacheItemPriority getPriority()
The relative cost of the object, as expressed by the enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.

Returns:
CacheItemPriority object of this item.
See Also:
CacheItemPriority

getResyncExpiredItems

public boolean getResyncExpiredItems()
Gets a value indicating whether the object when expired will cause a re-fetch of the object from the master datasource. (Resync Expired Items)

Returns:
true/false

getResyncProviderName

public java.lang.String getResyncProviderName()
Returns:
provider used for re-synchronization of item

getSlidingExpiration

public TimeSpan getSlidingExpiration()
The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.

Returns:
Date object specifying the sliding period for this item.

getSubGroup

public java.lang.String getSubGroup()
SubGroup name, this caheItem is to be included in

Returns:
SubGroup name

getTags

public Tag[] getTags()
gets all tags this CacheItem is attached to

Returns:
Array of tags

getValue

public java.lang.Object getValue()
The payload for this item.

Returns:
The value of the item.

getVersion

public CacheItemVersion getVersion()
Item version of the object, used when getCachItem is used on Cache

Returns:
See Also:
Cache

setAbsoluteExpiration

public void setAbsoluteExpiration(java.util.Date absoluteExpiration)
Sets the time at which the added object expires and is removed from the cache.

Parameters:
absoluteExpiration - Sets the time at which the added object expires and is removed from the cache.

setAsyncItemAddedCallback

public void setAsyncItemAddedCallback(AsyncItemAddedCallback itemAddedCallback)
An instance that, if provided, is called when an Asynchronous request for Add Operation completes. You can use this to obtain the results of an 'AddAsync' operation.

Parameters:
itemAddedCallback -
See Also:
AsyncItemAddedCallback

setAsyncItemUpdatedCallback

public void setAsyncItemUpdatedCallback(AsyncItemUpdatedCallback itemUpdatedCallback)
An instance that, if provided, is called when an Asynchronous request for Update Operation completes. You can use this to obtain the results of an 'InsertAsync' operation.

Parameters:
itemUpdatedCallback -
See Also:
AsyncItemUpdatedCallback

setCacheDependency

public void setCacheDependency(CacheDependency dependency)
Parameters:
dependency - Sets the CacheDependency of this Item.

The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this property contains a null reference

See Also:
CacheDependency

setCacheSyncDependency

public void setCacheSyncDependency(CacheSyncDependency syncDependency)
The cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this property contains a null reference.

Parameters:
syncDependency - instance of CacheSyncDependency
See Also:
CacheSyncDependency

setGroup

public void setGroup(java.lang.String group)
The name of the group to associate with the cache item. All cache items with the same group name are logically grouped together.

Parameters:
group - string, cannot be null of subgroup is existent

setItemRemoveCallback

public void setItemRemoveCallback(CacheItemRemovedCallback itemRemoveCallback)
An instance that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their Objects are deleted from the cache.

Parameters:
itemRemoveCallback - instance of the callback
See Also:
CacheItemRemovedCallback

setItemUpdateCallback

public void setItemUpdateCallback(CacheItemUpdatedCallback itemUpdateCallback)
An instance that, if provided, is called when an object is updated in the cache. You can use this to notify applications when their objects are updated in the cache.

Parameters:
itemUpdateCallback -
See Also:
CacheItemUpdatedCallback

setNamedTags

public void setNamedTags(NamedTagsDictionary namedTags)
Parameters:
namedTags - Sets the value of the named tags

setPriority

public void setPriority(CacheItemPriority priority)
Parameters:
priority - The relative cost of the object, as expressed by the enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.
See Also:
CacheItemPriority

setPriority

public void setPriority(int p)
Set priority using integer value

Parameters:
p -
See Also:
CacheItemPriority

setResyncExpiredItems

public void setResyncExpiredItems(boolean resync)
Parameters:
resync - Sets a value indicating whether the object when expired will cause a re-fetch of the object from the master datasource. (Resync Expired Items).

setResyncProviderName

public void setResyncProviderName(java.lang.String resyncProviderName)
Parameters:
resyncProviderName - provider used for re-synchronization of item

setSlidingExpiration

public void setSlidingExpiration(TimeSpan slidingExpiration)
Parameters:
slidingExpiration - The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.

setSubGroup

public void setSubGroup(java.lang.String subGroup)
The name of the sub-group within a group. This hierarchical grouping gives more control over the cache items.

Parameters:
subGroup - string, cannot be null if group is existent

setTags

public void setTags(Tag[] tags)
sets all tags this CacheItem is to be attached to

Parameters:
tags - Array of tag names, cannot contain null

setValue

public void setValue(java.lang.Object value)
Parameters:
value - Sets the value of the CacheItem.

setVersion

public void setVersion(CacheItemVersion version)
Sets Item Version

Parameters:
version -