Photon Server API
Public Member Functions | Protected Member Functions | Properties | List of all members
ExitGames.Threading.CachedSingletonFactory.CachedSingletonFactorySliding< TKey, TValue > Class Template Reference

A SynchronizedCachedSingletonFactory<TKey,TValue> for sliding caching. More...

Inheritance diagram for ExitGames.Threading.CachedSingletonFactory.CachedSingletonFactorySliding< TKey, TValue >:
ExitGames.Threading.CachedSingletonFactory.SynchronizedCachedSingletonFactory< TKey, TValue >

Public Member Functions

 CachedSingletonFactorySliding (CreateMethodDelegate< TKey, TValue > defaultCreateMethod, Action< TKey, TValue > removeCallback, TimeSpan cacheTimeSpan, int lockTimeout)
 Initializes a new instance of the CachedSingletonFactorySliding<TKey,TValue> class. More...
 
- Public Member Functions inherited from ExitGames.Threading.CachedSingletonFactory.SynchronizedCachedSingletonFactory< TKey, TValue >
virtual TValue Get (TKey key, CreateMethodDelegate< TKey, TValue > createMethod)
 Gets an existing value for a key or creates a new one. More...
 
TValue Get (TKey key)
 Gets an existing value for a key or creates a new one with the default DoCreateMethod. More...
 
TValue GetBlockingInstance (TKey key)
 Gets an existing value for a key or creates a new one with the default DoCreateMethod. The creation of a new instance is guarded with a sync root that is unique per key. This algorithm is ideal for creation methods that do not return fast. More...
 
TValue GetBlockingInstance (TKey key, CreateMethodDelegate< TKey, TValue > createMethod)
 Gets an existing value for a key or creates a new one. The creation of a new instance is guarded with a sync root that is unique per key. This algorithm is ideal for creation methods that do not return fast. More...
 
TValue GetBlockingOverall (TKey key)
 Gets an existing value for a key or creates a new one with the default DoCreateMethod. The creation of a new instance is guarded with a global SynchronizedSingletonFactory<TKey,TValue>.WriterLock. This algorithm is ideal for creation methods that return very fast. More...
 
TValue GetBlockingOverall (TKey key, CreateMethodDelegate< TKey, TValue > createMethod)
 Gets an existing value for a key or creates a new one. The creation of a new instance is guarded with a global SynchronizedSingletonFactory<TKey,TValue>.WriterLock. This algorithm is ideal for creation methods that return very fast. More...
 
TValue GetNonBlocking (TKey key)
 Gets an existing value for a key or creates a new one with the default DoCreateMethod. The creation of a new instance is not guarded. This introduces a risk that the creation method is called multiple times for the same key at the same time. Only one of the created values is added. This algorithm is ideal for creation methods that are either not likely to be called multiple times at the same time or that have an unpredictable execution time and a low usage of local reosurces. More...
 
TValue GetNonBlocking (TKey key, CreateMethodDelegate< TKey, TValue > createMethod)
 Gets an existing value for a key or creates a new one. The creation of a new instance is not guarded. This introduces a risk that the creation method is called multiple times for the same key at the same time. Only one of the created values is added. This algorithm is ideal for creation methods that are either not likely to be called multiple times at the same time or that have an unpredictable execution time and a low usage of local reosurces. More...
 
override bool Remove (CacheKey< TKey, TValue > key)
 Removes a value from the cache and from the SynchronizedSingletonFactory<TKey,TValue>.Instances. More...
 
bool Remove (TKey key)
 Removes a value from the cache and from the SynchronizedSingletonFactory<TKey,TValue>.Instances. More...
 
override bool TryGet (CacheKey< TKey, TValue > key, out CacheValue< TKey, TValue > value)
 Tries to get an existing value for the key. More...
 
virtual bool TryGet (TKey key, out TValue value)
 Tries to get an existing value for the key. More...
 

Protected Member Functions

override void InsertIntoCache (string key, CacheValue< TKey, TValue > instance, TimeSpan cacheTimeSpan, CacheItemRemovedCallback callback)
 Inserts an item into the cache with a sliding timeout. More...
 
- Protected Member Functions inherited from ExitGames.Threading.CachedSingletonFactory.SynchronizedCachedSingletonFactory< TKey, TValue >
 SynchronizedCachedSingletonFactory (CreateMethodDelegate< TKey, TValue > defaultCreateMethod, Action< TKey, TValue > removeCallback, TimeSpan cacheTimeSpan, int lockTimeout)
 Initializes a new instance of the SynchronizedCachedSingletonFactory<TKey,TValue> class. More...
 
override void DoAdd (CacheKey< TKey, TValue > key, CacheValue< TKey, TValue > value)
 Adds a value to the SynchronizedSingletonFactory<TKey,TValue>.Instances and the cache. Calling methods need to guard the SynchronizedSingletonFactory<TKey,TValue>.Instances with a SynchronizedSingletonFactory<TKey,TValue>.WriterLock. Calling methods are: SynchronizedSingletonFactory<TKey,TValue>.Add, GetBlockingInstance, GetNonBlocking and GetBlockingOverall. More...
 

Properties

override TimeSpan CacheTimeOut [get, set]
 Gets or sets the time until items are removed from the cache after the last access. More...
 
- Properties inherited from ExitGames.Threading.CachedSingletonFactory.SynchronizedCachedSingletonFactory< TKey, TValue >
virtual TimeSpan CacheTimeOut [get, set]
 Gets or sets the caching timeout. More...
 
CreateMethodDelegate< TKey, TValue > DoCreateMethod [get, set]
 Gets or sets the default creation method. More...
 
Action< TKey, TValue > RemoveCallback [get, set]
 Gets or sets the callback for removed items. More...
 
Cache Cache [get]
 Gets the asp net cache. More...
 

Detailed Description

A SynchronizedCachedSingletonFactory<TKey,TValue> for sliding caching.

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

Constructor & Destructor Documentation

ExitGames.Threading.CachedSingletonFactory.CachedSingletonFactorySliding< TKey, TValue >.CachedSingletonFactorySliding ( CreateMethodDelegate< TKey, TValue >  defaultCreateMethod,
Action< TKey, TValue >  removeCallback,
TimeSpan  cacheTimeSpan,
int  lockTimeout 
)
inline

Initializes a new instance of the CachedSingletonFactorySliding<TKey,TValue> class.

Parameters
defaultCreateMethodThe default create method.
removeCallbackThe remove callback.
cacheTimeSpanThe cache time span.
lockTimeoutThe lock timeout in ms.

Member Function Documentation

override void ExitGames.Threading.CachedSingletonFactory.CachedSingletonFactorySliding< TKey, TValue >.InsertIntoCache ( string  key,
CacheValue< TKey, TValue >  instance,
TimeSpan  cacheTimeSpan,
CacheItemRemovedCallback  callback 
)
inlineprotectedvirtual

Inserts an item into the cache with a sliding timeout.

Parameters
keyThe key.
instanceThe instance.
cacheTimeSpanThe cache time span.
callbackThe remove callback.

Implements ExitGames.Threading.CachedSingletonFactory.SynchronizedCachedSingletonFactory< TKey, TValue >.

Property Documentation

override TimeSpan ExitGames.Threading.CachedSingletonFactory.CachedSingletonFactorySliding< TKey, TValue >.CacheTimeOut
getset

Gets or sets the time until items are removed from the cache after the last access.