Class LocalCache.Entry
A holder for a cached value.
Inherited Members
Namespace: Tangosol.Net.Cache
Assembly: Coherence.dll
Syntax
public class LocalCache.Entry : IInvocableCacheEntry, IConfigurableCacheEntry, ICacheEntry
Constructors
Entry(LocalCache, object, object)
Construct the cacheable entry that holds the cached value.
Declaration
public Entry(LocalCache localCache, object key, object value)
Parameters
Type | Name | Description |
---|---|---|
LocalCache | localCache | The local cache for this entry. |
object | key | The key of this entry. |
object | value | The value of this entry. |
Fields
m_cache
Parent cache.
Declaration
protected LocalCache m_cache
Field Value
Type | Description |
---|---|
LocalCache |
m_key
Entry's key.
Declaration
protected object m_key
Field Value
Type | Description |
---|---|
object |
m_value
Entry's value.
Declaration
protected object m_value
Field Value
Type | Description |
---|---|
object |
Properties
Cache
Parent cache.
Declaration
public virtual LocalCache Cache { get; set; }
Property Value
Type | Description |
---|---|
LocalCache | Parent cache. |
CreatedMillis
Determine when the cache entry was created.
Declaration
public virtual long CreatedMillis { get; }
Property Value
Type | Description |
---|---|
long | The date/time value, in millis, when the entry was created. |
ExpiryMillis
Determine when the cache entry will expire, if ever.
Declaration
public virtual long ExpiryMillis { get; set; }
Property Value
Type | Description |
---|---|
long | The date/time value, in millis, when the entry will (or did) expire; zero indicates no expiry. |
Remarks
Note that if the cache is configured for automatic expiry, each subsequent update to this cache entry will reschedule the expiry time.
IsDiscarded
Determine if this entry has already been discarded from the cache.
Declaration
protected virtual bool IsDiscarded { get; }
Property Value
Type | Description |
---|---|
bool | true if this entry has been discarded. |
IsExpired
Determine if the cache entry has expired.
Declaration
public virtual bool IsExpired { get; }
Property Value
Type | Description |
---|---|
bool | true if the cache entry was subject to automatic expiry and the current time is greater than the entry's expiry time. |
IsPresent
Determine if this entry exists in the cache.
Declaration
public virtual bool IsPresent { get; }
Property Value
Type | Description |
---|---|
bool | true if this entry exists in the containing cache. |
Remarks
If the entry is not present, it can be created by setting the Value property. If the entry is present, it can be destroyed by calling Remove(bool).
Key
Gets the key corresponding to this entry.
Declaration
public virtual object Key { get; }
Property Value
Type | Description |
---|---|
object | The key corresponding to this entry; may be |
LastTouchMillis
Determine when the cache entry was last touched.
Declaration
public virtual long LastTouchMillis { get; }
Property Value
Type | Description |
---|---|
long | The date/time value, in millis, when the entry was most recently touched. |
Priority
Calculate a cache priority.
Declaration
public virtual int Priority { get; }
Property Value
Type | Description |
---|---|
int | A value between 0 and 10, 0 being the highest priority. |
TouchCount
Determine the number of times that the cache entry has been touched.
Declaration
public virtual int TouchCount { get; }
Property Value
Type | Description |
---|---|
int | The number of times that the cache entry has been touched. |
Units
Determine the number of cache units used by this Entry.
Declaration
public virtual int Units { get; set; }
Property Value
Type | Description |
---|---|
int | An integer value 0 or greater, with a larger value signifying a higher cost; -1 implies that the Entry has been discarded. |
Value
Gets or sets the value corresponding to this entry.
Declaration
public virtual object Value { get; set; }
Property Value
Type | Description |
---|---|
object | The value corresponding to this entry; may be |
Methods
CalculateUnits(object)
Calculate a cache cost for the specified object.
Declaration
public virtual int CalculateUnits(object value)
Parameters
Type | Name | Description |
---|---|---|
object | value | The cache value to evaluate for unit cost. |
Returns
Type | Description |
---|---|
int | An integer value 0 or greater, with a larger value signifying a higher cost. |
Remarks
The default implementation uses the unit calculator type of the containing cache.
Discard()
Called to inform the Entry that it is no longer used.
Declaration
protected virtual void Discard()
Remarks
This method should only be called while holding the LocalCache write lock.
Extract(IValueExtractor)
Extract a value out of the entry's value.
Declaration
public virtual object Extract(IValueExtractor extractor)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | An IValueExtractor to apply to the entry's value |
Returns
Type | Description |
---|---|
object | The extracted value. |
Remarks
Calling this method is semantically equivalent to extractor.Extract(entry.Value), but this method may be significantly less expensive because the resultant value may be obtained from a forward index, for example.
IndexOfMSB(int)
Determine the most significant bit of the passed integral value.
Declaration
public virtual int IndexOfMSB(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n | An int. |
Returns
Type | Description |
---|---|
int | -1 if no bits are set; otherwise, the bit position p of the most significant bit such that 1 << p is the most significant bit of n |
Remove(bool)
Remove this entry from the cache if it is present in the cache.
Declaration
public virtual void Remove(bool isSynthetic)
Parameters
Type | Name | Description |
---|---|---|
bool | isSynthetic | Pass true only if the removal from the dictionary should be treated as a synthetic event. |
Remarks
This method supports both the operation corresponding to IDictionary.Remove as well as synthetic operations such as eviction. If the containing cache does not differentiate between the two, then this method will always be identical to IInvocableCache.Remove(Key).
ResetTouchCount()
Reset the number of times that the cache entry has been touched.
Declaration
public void ResetTouchCount()
Remarks
The touch count does not get reset to zero, but rather to a fraction of its former self; this prevents long lived items from gaining an unasailable advantage in the eviction process.
ScheduleExpiry()
Reschedule the cache entry expiration.
Declaration
protected virtual void ScheduleExpiry()
SetValue(object, bool)
Store the value corresponding to this entry.
Declaration
public virtual void SetValue(object value, bool isSynthetic)
Parameters
Type | Name | Description |
---|---|---|
object | value | The new value for this entry. |
bool | isSynthetic | Pass true only if the insertion into or modification of the cache should be treated as a synthetic event. |
Remarks
If the entry does not exist, then the entry will be created by
invoking this method, even with a null
value (assuming the
cache supports null
values).
Unlike the property Value, this method does not return the previous value, and as a result may be significantly less expensive (in terms of cost of execution) for certain cache implementations.
ToString()
Render the cache entry as a string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The details about this Entry. |
Overrides
Touch()
Called each time the entry is accessed or modified.
Declaration
public virtual void Touch()
Update(IValueUpdater, object)
Update the entry's value.
Declaration
public virtual void Update(IValueUpdater updater, object value)
Parameters
Type | Name | Description |
---|---|---|
IValueUpdater | updater | An IValueUpdater used to modify the entry's value. |
object | value | Value to update target object to. |
Remarks
Calling this method is semantically equivalent to:
object target = entry.Value; updater.Update(target, value); entry.Value = target;
The benefit of using this method is that it may allow the entry implementation to significantly optimize the operation, such as for purposes of delta updates and backup maintenance.
Operators
implicit operator DictionaryEntry(Entry)
Converts Entry to DictionaryEntry.
Declaration
public static implicit operator DictionaryEntry(LocalCache.Entry entry)
Parameters
Type | Name | Description |
---|---|---|
LocalCache.Entry | entry | Entry instance. |
Returns
Type | Description |
---|---|
DictionaryEntry | DictionaryEntry with key and value extracted from the specified Entry. |
implicit operator CacheEntry(Entry)
Converts Entry to CacheEntry.
Declaration
public static implicit operator CacheEntry(LocalCache.Entry entry)
Parameters
Type | Name | Description |
---|---|---|
LocalCache.Entry | entry | Entry instance. |
Returns
Type | Description |
---|---|
CacheEntry | CacheEntry with key and value extracted from the specified Entry. |