OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Properties | List of all members
OpenSim.Framework.ICnmCache< TKey, TValue > Interface Template Reference

Represent generic cache to store key/value pairs (elements) limited by time, size and count of elements. More...

Inheritance diagram for OpenSim.Framework.ICnmCache< TKey, TValue >:
Inheritance graph
[legend]
Collaboration diagram for OpenSim.Framework.ICnmCache< TKey, TValue >:
Collaboration graph
[legend]

Public Member Functions

void Clear ()
 Removes all elements from the ICnmCache{TKey,TValue}. More...
 
void PurgeExpired ()
 Purge expired elements from the ICnmCache{TKey,TValue}. More...
 
void Remove (TKey key)
 Removes element associated with key from the ICnmCache{TKey,TValue}. More...
 
void RemoveRange (IEnumerable< TKey > keys)
 Removes elements that are associated with one of keys from the ICnmCache{TKey,TValue}. More...
 
bool Set (TKey key, TValue value, long size)
 Add or replace an element with the provided key , value and size to ICnmCache{TKey,TValue}. More...
 
bool TryGetValue (TKey key, out TValue value)
 Gets the value associated with the specified key . More...
 

Properties

int Count [get]
 Gets current count of elements stored to ICnmCache{TKey,TValue}. More...
 
TimeSpan ExpirationTime [get, set]
 Gets or sets elements expiration time. More...
 
bool IsSynchronized [get]
 Gets a value indicating whether or not access to the ICnmCache{TKey,TValue} is synchronized (thread safe). More...
 
bool IsCountLimited [get]
 Gets a value indicating whether ICnmCache{TKey,TValue} is limiting count of elements. More...
 
bool IsSizeLimited [get]
 Gets a value indicating whether ICnmCache{TKey,TValue} is limiting size of elements. More...
 
bool IsTimeLimited [get]
 Gets a value indicating whether elements stored to ICnmCache{TKey,TValue} have limited inactivity time. More...
 
int MaxCount [get, set]
 Gets or sets maximal allowed count of elements that can be stored to ICnmCache{TKey,TValue}. More...
 
long MaxElementSize [get]
 
long MaxSize [get, set]
 Gets or sets maximal allowed total size for elements stored to ICnmCache{TKey,TValue}. More...
 
long Size [get]
 Gets total size of elements stored to ICnmCache{TKey,TValue}. More...
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the ICnmCache{TKey,TValue}. More...
 

Detailed Description

Represent generic cache to store key/value pairs (elements) limited by time, size and count of elements.

Template Parameters
TKeyThe type of keys in the cache.
TValueThe type of values in the cache.

Cache store limitations:

Limitation Description
Time Element that is not accessed through TryGetValue or Set in last ExpirationTime are removed from the cache automatically. Depending on implementation of the cache some of elements may stay longer in cache. IsTimeLimited returns , if cache is limited by time.
Count When adding an new element to cache that already have MaxCount of elements, cache will remove less recently used element(s) from the cache, until element fits to cache. IsCountLimited returns , if cache is limiting element count.
Size When adding an new element to cache that already have MaxSize of elements, cache will remove less recently used element(s) from the cache, until element fits to cache. IsSizeLimited returns , if cache is limiting total size of elements. Normally size is bytes used by element in the cache. But it can be any other suitable unit of measure.

Definition at line 80 of file ICnmCache.cs.

Member Function Documentation

void OpenSim.Framework.ICnmCache< TKey, TValue >.Clear ( )
void OpenSim.Framework.ICnmCache< TKey, TValue >.PurgeExpired ( )

Purge expired elements from the ICnmCache{TKey,TValue}.

Element becomes expired when last access time to it has been longer time than ExpirationTime.

Depending on ICnmCache{TKey,TValue} implementation, some of expired elements may stay longer than ExpirationTime in the cache.

See Also
IsTimeLimited, ExpirationTime, Set, Remove, RemoveRange, TryGetValue, Clear

Implemented in OpenSim.Framework.CnmMemoryCache< TKey, TValue >, and OpenSim.Framework.CnmSynchronizedCache< TKey, TValue >.

void OpenSim.Framework.ICnmCache< TKey, TValue >.Remove ( TKey  key)

Removes element associated with key from the ICnmCache{TKey,TValue}.

Parameters
keyThe key that is associated with element to remove from the ICnmCache{TKey,TValue}.
Exceptions
ArgumentNullExceptionkey is .
See Also
Set, RemoveRange, TryGetValue, Clear, PurgeExpired

Implemented in OpenSim.Framework.CnmMemoryCache< TKey, TValue >, and OpenSim.Framework.CnmSynchronizedCache< TKey, TValue >.

void OpenSim.Framework.ICnmCache< TKey, TValue >.RemoveRange ( IEnumerable< TKey >  keys)

Removes elements that are associated with one of keys from the ICnmCache{TKey,TValue}.

Parameters
keysThe keys that are associated with elements to remove from the ICnmCache{TKey,TValue}.
Exceptions
ArgumentNullExceptionkeys is .
See Also
Set, Remove, TryGetValue, Clear, PurgeExpired

Implemented in OpenSim.Framework.CnmMemoryCache< TKey, TValue >, and OpenSim.Framework.CnmSynchronizedCache< TKey, TValue >.

bool OpenSim.Framework.ICnmCache< TKey, TValue >.Set ( TKey  key,
TValue  value,
long  size 
)

Add or replace an element with the provided key , value and size to ICnmCache{TKey,TValue}.

Parameters
keyThe object used as the key of the element. Can't be reference.
valueThe object used as the value of the element to add or replace. is allowed.
sizeThe element's size. Normally bytes, but can be any suitable unit of measure.
Returns
if element has been added successfully to the ICnmCache{TKey,TValue}; otherwise .
Exceptions
ArgumentNullExceptionkey is .
ArgumentOutOfRangeExceptionThe element's size is less than 0.

If element's size is larger than MaxElementSize, then element is not added to the ICnmCache{TKey,TValue}, however - possible older element is removed from the ICnmCache{TKey,TValue}.

When adding an new element to ICnmCache{TKey,TValue} that is limiting total size of elements, ICnmCache{TKey,TValue}will remove less recently used elements until it can fit an new element.

When adding an new element to ICnmCache{TKey,TValue} that is limiting element count, ICnmCache{TKey,TValue}will remove less recently used elements until it can fit an new element.

See Also
IsSizeLimited, IsCountLimited, Remove, RemoveRange, TryGetValue, Clear, PurgeExpired

Implemented in OpenSim.Framework.CnmMemoryCache< TKey, TValue >, and OpenSim.Framework.CnmSynchronizedCache< TKey, TValue >.

bool OpenSim.Framework.ICnmCache< TKey, TValue >.TryGetValue ( TKey  key,
out TValue  value 
)

Gets the value associated with the specified key .

Returns
if the ICnmCache{TKey,TValue} contains an element with the specified key; otherwise, .
Parameters
keyThe key whose value to get.
valueWhen this method returns, the value associated with the specified key , if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Exceptions
ArgumentNullExceptionkey is .
See Also
Set, Remove, RemoveRange, Clear, PurgeExpired

Implemented in OpenSim.Framework.CnmMemoryCache< TKey, TValue >, and OpenSim.Framework.CnmSynchronizedCache< TKey, TValue >.

Property Documentation

int OpenSim.Framework.ICnmCache< TKey, TValue >.Count
get

Gets current count of elements stored to ICnmCache{TKey,TValue}.

When adding an new element to ICnmCache{TKey,TValue} that is limiting element count, ICnmCache{TKey,TValue} will remove less recently used elements until it can fit an new element.

See Also
MaxCount, IsCountLimited, IsSizeLimited, IsTimeLimited

Definition at line 95 of file ICnmCache.cs.

TimeSpan OpenSim.Framework.ICnmCache< TKey, TValue >.ExpirationTime
getset

Gets or sets elements expiration time.

Elements expiration time.

When element has been stored in ICnmCache{TKey,TValue} longer than ExpirationTime and it is not accessed through TryGetValue method or element's value is not replaced by Set method, then it is automatically removed from the ICnmCache{TKey,TValue}.

It is possible that ICnmCache{TKey,TValue} implementation removes element before it's expiration time, because total size or count of elements stored to cache is larger than MaxSize or MaxCount.

It is also possible that element stays in cache longer than ExpirationTime.

Calling PurgeExpired try to remove all elements that are expired.

To disable time limit in cache, set ExpirationTime to DateTime.MaxValue.

See Also
IsTimeLimited, IsCountLimited, IsSizeLimited, PurgeExpired, Count, MaxCount, MaxSize, Size

Definition at line 132 of file ICnmCache.cs.

bool OpenSim.Framework.ICnmCache< TKey, TValue >.IsCountLimited
get

Gets a value indicating whether ICnmCache{TKey,TValue} is limiting count of elements.

if the ICnmCache{TKey,TValue} count of elements is limited; otherwise, .

When adding an new element to ICnmCache{TKey,TValue} that is limiting element count, ICnmCache{TKey,TValue} will remove less recently used elements until it can fit an new element.

See Also
Count, MaxCount, IsSizeLimited, IsTimeLimited

Definition at line 169 of file ICnmCache.cs.

bool OpenSim.Framework.ICnmCache< TKey, TValue >.IsSizeLimited
get

Gets a value indicating whether ICnmCache{TKey,TValue} is limiting size of elements.

if the ICnmCache{TKey,TValue} total size of elements is limited; otherwise, .

When adding an new element to ICnmCache{TKey,TValue} that is limiting total size of elements, ICnmCache{TKey,TValue} will remove less recently used elements until it can fit an new element.

See Also
MaxElementSize, Size, MaxSize, IsCountLimited, IsTimeLimited

Definition at line 189 of file ICnmCache.cs.

bool OpenSim.Framework.ICnmCache< TKey, TValue >.IsSynchronized
get

Gets a value indicating whether or not access to the ICnmCache{TKey,TValue} is synchronized (thread safe).

if access to the ICnmCache{TKey,TValue} is synchronized (thread safe); otherwise, .

To get synchronized (thread safe) access to ICnmCache{TKey,TValue} object, use CnmSynchronizedCache{TKey,TValue}.Synchronized in CnmSynchronizedCache{TKey,TValue} class to retrieve synchronized wrapper for ICnmCache{TKey,TValue} object.

See Also
SyncRoot, CnmSynchronizedCache{TKey,TValue}

Definition at line 150 of file ICnmCache.cs.

bool OpenSim.Framework.ICnmCache< TKey, TValue >.IsTimeLimited
get

Gets a value indicating whether elements stored to ICnmCache{TKey,TValue} have limited inactivity time.

if the ICnmCache{TKey,TValue} has a fixed total size of elements; otherwise, .

If ICnmCache{TKey,TValue} have limited inactivity time and element is not accessed through Set or TryGetValue methods in ExpirationTime , then element is automatically removed from the cache. Depending on implementation of the ICnmCache{TKey,TValue}, some of the elements may stay longer in cache.

See Also
ExpirationTime, PurgeExpired, IsCountLimited, IsSizeLimited

Definition at line 208 of file ICnmCache.cs.

int OpenSim.Framework.ICnmCache< TKey, TValue >.MaxCount
getset

Gets or sets maximal allowed count of elements that can be stored to ICnmCache{TKey,TValue}.

int.MaxValue, if ICnmCache{TKey,TValue} is not limited by count of elements; otherwise maximal allowed count of elements.

When adding an new element to ICnmCache{TKey,TValue} that is limiting element count, ICnmCache{TKey,TValue} will remove less recently used elements until it can fit an new element.

Definition at line 223 of file ICnmCache.cs.

long OpenSim.Framework.ICnmCache< TKey, TValue >.MaxElementSize
get

Gets maximal allowed element size.

Maximal allowed element size.

If element's size is larger than MaxElementSize, then element is not added to the ICnmCache{TKey,TValue}.

See Also
Set, IsSizeLimited, Size, MaxSize

Definition at line 241 of file ICnmCache.cs.

long OpenSim.Framework.ICnmCache< TKey, TValue >.MaxSize
getset

Gets or sets maximal allowed total size for elements stored to ICnmCache{TKey,TValue}.

Maximal allowed total size for elements stored to ICnmCache{TKey,TValue}.

Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure.

When adding an new element to ICnmCache{TKey,TValue} that is limiting total size of elements, ICnmCache{TKey,TValue} will remove less recently used elements until it can fit an new element.

Exceptions
ArgumentOutOfRangeExceptionvalue is less than 0.
See Also
MaxElementSize, IsSizeLimited, Size

Definition at line 262 of file ICnmCache.cs.

long OpenSim.Framework.ICnmCache< TKey, TValue >.Size
get

Gets total size of elements stored to ICnmCache{TKey,TValue}.

Total size of elements stored to ICnmCache{TKey,TValue}.

Normally bytes, but can be any suitable unit of measure.

Element's size is given when element is added or replaced by Set method.

When adding an new element to ICnmCache{TKey,TValue} that is limiting total size of elements, ICnmCache{TKey,TValue} will remove less recently used elements until it can fit an new element.

See Also
MaxElementSize, IsSizeLimited, MaxSize, IsCountLimited, ExpirationTime

Definition at line 287 of file ICnmCache.cs.

object OpenSim.Framework.ICnmCache< TKey, TValue >.SyncRoot
get

Gets an object that can be used to synchronize access to the ICnmCache{TKey,TValue}.

An object that can be used to synchronize access to the ICnmCache{TKey,TValue}.

To get synchronized (thread safe) access to ICnmCache{TKey,TValue}, use CnmSynchronizedCache{TKey,TValue} method CnmSynchronizedCache{TKey,TValue}.Synchronized to retrieve synchronized wrapper interface to ICnmCache{TKey,TValue}.

See Also
IsSynchronized, CnmSynchronizedCache{TKey,TValue}

Definition at line 304 of file ICnmCache.cs.


The documentation for this interface was generated from the following file: