C# Class Universe.Services.CenomeMemoryAssetCache

Cenome memory asset cache.

Cache is enabled by setting "AssetCaching" configuration to value "CenomeMemoryAssetCache". When cache is successfully enable log should have message "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = XXX bytes, MaxCount = XXX, ExpirationTime = XXX)".

Cache's size is limited by two parameters: maximal allowed size in bytes and maximal allowed asset count. When new asset is added to cache that have achieved either size or count limitation, cache will automatically remove less recently used assets from cache. Additionally asset's lifetime is controlled by expiration time.

Configuration Description MaxSize Maximal size of the cache in bytes. Default value: 128MB (134 217 728 bytes). MaxCount Maximal count of assets stored to cache. Default value: 4096 assets. ExpirationTime Asset's expiration time in minutes. Default value: 30 minutes.

Inheritance: IImprovedAssetCache, IService
Mostra file Open project: Virtual-Universe/Virtual-Universe

Public Properties

Property Type Description
DefaultExpirationTime System.TimeSpan

Public Methods

Method Description
Cache ( string assetID, AssetBase asset ) : void

Cache asset.

CacheData ( string assetID, byte asset ) : void
Clear ( ) : void

Clear asset cache.

Contains ( string id ) : bool
Expire ( string id ) : void

Expire (remove) asset stored to cache.

FinishedStartup ( ) : void
Get ( string id ) : AssetBase

Get asset stored

Caller should always check that is return value . Cache doesn't guarantee in any situation that asset is stored to it.

Get ( string id, bool &found ) : AssetBase
GetData ( string id, bool &found ) : byte[]
Initialize ( IConfigSource config, IRegistryCore registry ) : void
Start ( IConfigSource config, IRegistryCore registry ) : void

Protected Methods

Method Description
Initialize ( long maximalSize, int maximalCount, System.TimeSpan expirationTime ) : void

Initialize asset cache module, with custom parameters.

Method Details

Cache() public method

Cache asset.
public Cache ( string assetID, AssetBase asset ) : void
assetID string
asset Universe.Framework.Services.ClassHelpers.Assets.AssetBase /// The asset that is being cached. ///
return void

CacheData() public method

public CacheData ( string assetID, byte asset ) : void
assetID string
asset byte
return void

Clear() public method

Clear asset cache.
public Clear ( ) : void
return void

Contains() public method

public Contains ( string id ) : bool
id string
return bool

Expire() public method

Expire (remove) asset stored to cache.
public Expire ( string id ) : void
id string /// The expired asset's id. ///
return void

FinishedStartup() public method

public FinishedStartup ( ) : void
return void

Get() public method

Get asset stored

Caller should always check that is return value . Cache doesn't guarantee in any situation that asset is stored to it.

public Get ( string id ) : AssetBase
id string /// The asset's id. ///
return Universe.Framework.Services.ClassHelpers.Assets.AssetBase

Get() public method

public Get ( string id, bool &found ) : AssetBase
id string
found bool
return Universe.Framework.Services.ClassHelpers.Assets.AssetBase

GetData() public method

public GetData ( string id, bool &found ) : byte[]
id string
found bool
return byte[]

Initialize() public method

public Initialize ( IConfigSource config, IRegistryCore registry ) : void
config IConfigSource
registry IRegistryCore
return void

Initialize() protected method

Initialize asset cache module, with custom parameters.
protected Initialize ( long maximalSize, int maximalCount, System.TimeSpan expirationTime ) : void
maximalSize long /// Cache's maximal size in bytes. ///
maximalCount int /// Cache's maximal count of assets. ///
expirationTime System.TimeSpan /// Asset's expiration time. ///
return void

Start() public method

public Start ( IConfigSource config, IRegistryCore registry ) : void
config IConfigSource
registry IRegistryCore
return void

Property Details

DefaultExpirationTime public_oe static_oe property

Asset's default expiration time in the cache.
public static TimeSpan,System DefaultExpirationTime
return System.TimeSpan