Table of Contents

Interface ICache

Namespace
MoonBark.GridPlacement.Core.Interfaces
Assembly
MoonBark.GridPlacement.Core.dll

Simplified cache interface for string keys (most common use case).

public interface ICache : ICache<string, object>
Inherited Members

Methods

GetOrAdd<T>(string, Func<T>)

Gets a typed value from the cache, or creates it if it doesn't exist.

T GetOrAdd<T>(string key, Func<T> factory)

Parameters

key string

The cache key

factory Func<T>

Function to create the value if not cached

Returns

T

The cached or newly created value

Type Parameters

T

The value type

Get<T>(string)

Gets a typed value from the cache.

T Get<T>(string key)

Parameters

key string

The cache key

Returns

T

The cached value

Type Parameters

T

The value type

Set<T>(string, T)

Sets a typed value in the cache.

void Set<T>(string key, T value)

Parameters

key string

The cache key

value T

The value to cache

Type Parameters

T

The value type

TryGetValue<T>(string, out T)

Attempts to get a typed value from the cache.

bool TryGetValue<T>(string key, out T value)

Parameters

key string

The cache key

value T

The cached value if found

Returns

bool

True if the value was found and has correct type, false otherwise

Type Parameters

T

The value type