Version 2.1.0.0

Cache<T> class

Namespace: Sirenix.Serialization.Utilities
Assembly: Sirenix.Serialization
public sealed class Cache<T> : ICache<T>, IDisposable where T : class, new()
Provides an easy way of claiming and freeing cached values of any non-abstract reference type with a public parameterless constructor.

Cached types which implement the Sirenix.Serialization.Utilities.ICacheNotificationReceiver interface will receive notifications when they are claimed and freed.

Inheritance
  • System.Object
  • Cache<T>
See Also
  • System.IDisposable

Type Parameters

T

The type which is cached.

Properties

MaxCacheSize
Gets or sets the maximum size of the cache. This value can never go beneath 1.
public static int MaxCacheSize { get; set; }
Value
Gets the cached value.
public T Value { get; }
Exceptions
System.InvalidOperationException

Cannot access a cache while it is freed.

Methods

Claim()
Claims a cached value of type .
public static Cache<T> Claim()
Returns
Cache<T>

A cached value of type .

Release(Cache<T>)
Releases a cached value.
public static void Release(Cache<T> cache)
Parameters
Cache<T> cache

The cached value to release.

Exceptions
System.ArgumentNullException

The cached value to release is null.

Operators

Implicit(Cache<T> to T)
Performs an implicit conversion from Cache<T> to .
public static implicit operator T(Cache<T> cache)
Parameters
Cache<T> cache

The cache to convert.

Returns
T

The result of the conversion.

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.