C# Класс 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.

Наследование: IImprovedAssetCache, IService
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
DefaultExpirationTime System.TimeSpan

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
Initialize ( long maximalSize, int maximalCount, System.TimeSpan expirationTime ) : void

Initialize asset cache module, with custom parameters.

Описание методов

Cache() публичный Метод

Cache asset.
public Cache ( string assetID, AssetBase asset ) : void
assetID string
asset Universe.Framework.Services.ClassHelpers.Assets.AssetBase /// The asset that is being cached. ///
Результат void

CacheData() публичный Метод

public CacheData ( string assetID, byte asset ) : void
assetID string
asset byte
Результат void

Clear() публичный Метод

Clear asset cache.
public Clear ( ) : void
Результат void

Contains() публичный Метод

public Contains ( string id ) : bool
id string
Результат bool

Expire() публичный Метод

Expire (remove) asset stored to cache.
public Expire ( string id ) : void
id string /// The expired asset's id. ///
Результат void

FinishedStartup() публичный Метод

public FinishedStartup ( ) : void
Результат void

Get() публичный Метод

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. ///
Результат Universe.Framework.Services.ClassHelpers.Assets.AssetBase

Get() публичный Метод

public Get ( string id, bool &found ) : AssetBase
id string
found bool
Результат Universe.Framework.Services.ClassHelpers.Assets.AssetBase

GetData() публичный Метод

public GetData ( string id, bool &found ) : byte[]
id string
found bool
Результат byte[]

Initialize() публичный Метод

public Initialize ( IConfigSource config, IRegistryCore registry ) : void
config IConfigSource
registry IRegistryCore
Результат void

Initialize() защищенный Метод

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. ///
Результат void

Start() публичный Метод

public Start ( IConfigSource config, IRegistryCore registry ) : void
config IConfigSource
registry IRegistryCore
Результат void

Описание свойств

DefaultExpirationTime публичное статическое свойство

Asset's default expiration time in the cache.
public static TimeSpan,System DefaultExpirationTime
Результат System.TimeSpan