Skip to content

XyzLruCache<T>

Namespace: ThinkGeo.Core

Represents an in-memory, tile-indexed least-recently-used cache. Thread-safe via a single lock protecting both map and LRU list.

public class XyzLruCache<T>

Type Parameters

T

Inheritance objectXyzLruCache<T>

Properties

Capacity

Gets or sets the maximum number of items that can be stored in the cache. Setting it trims the cache immediately if needed.

public int Capacity { get; set; }

Property Value

int

Constructors

XyzLruCache(int)

Initializes a new instance of the XyzLruCache<T> class.

public XyzLruCache(int capacity)

Parameters

capacity int
The maximum number of cached items.

Methods

TryGet(int, long, long, T&)

Tries to get a tile from the cache. If found, updates LRU order (MRU).

public bool TryGet(int zoom, long x, long y, T& value)

Parameters

zoom int

x long

y long

value T&

Returns

bool

Get(int, long, long)

Gets a tile from the cache, returning default(T) if it does not exist.

public T Get(int zoom, long x, long y)

Parameters

zoom int

x long

y long

Returns

T

Add(int, long, long, T)

Adds or updates the given content in the cache, moving it to MRU. If capacity is exceeded, evicts LRU items.

public void Add(int zoom, long x, long y, T content)

Parameters

zoom int

x long

y long

content T

Returns

void

Remove(int, long, long)

Removes the specified tile from the cache, if it exists.

public bool Remove(int zoom, long x, long y)

Parameters

zoom int

x long

y long

Returns

bool

Clear()

Removes every cached entry and resets the usage order.

public void Clear()

Returns

void