Class CacheItem
Represents a cached asset item with its state and metadata.
Tracks the lifecycle of an asset within the prefetch cache system.
Inherited Members
Namespace: Serenity.AssetPrefetcher.Domain.Entities
Assembly: Serenity.AssetPrefetcher.Domain.dll
Syntax
public class CacheItem
Constructors
CacheItem(AssetKey, int)
Initializes a new cache item in the loading state.
Declaration
public CacheItem(AssetKey key, int sizeInBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetKey | key | The asset key for this cache item |
| int | sizeInBytes | The size of the asset in bytes |
Properties
AssetKey
Declaration
public AssetKey AssetKey { get; }
Property Value
| Type | Description |
|---|---|
| AssetKey | The unique key identifying the cached asset. |
AssetRef
Declaration
public object AssetRef { get; }
Property Value
| Type | Description |
|---|---|
| object | Reference to the actual loaded asset (null when not loaded or evicted). |
Remarks
Typed as object rather than the engine's native asset type because Domain
must not reference UnityEngine — the same pattern used for the template properties on
Serenity.Ui.Domain.Interfaces.IUiThemeComponents. The Unity-side infrastructure
layer casts back to UnityEngine.Object where it needs the concrete engine type.
SizeInBytes
Declaration
public int SizeInBytes { get; }
Property Value
| Type | Description |
|---|---|
| int | Size of the asset in bytes for memory management purposes. |
State
Declaration
public CacheItemState State { get; }
Property Value
| Type | Description |
|---|---|
| CacheItemState | Current state of the cache item in its lifecycle. |
Methods
Evict()
Evicts the cache item, removing the asset reference and marking it as evicted.
Declaration
public void Evict()
SetReady(object)
Marks the cache item as ready and associates it with the loaded asset.
Declaration
public void SetReady(object asset)
Parameters
| Type | Name | Description |
|---|---|---|
| object | asset | The loaded asset object (engine-agnostic; see AssetRef) |