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 Object → XyzLruCache<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¶
Constructors¶
XyzLruCache(Int32)¶
Initializes a new instance of the XyzLruCache<T> class.
public XyzLruCache(int capacity)
Parameters¶
capacity Int32
The maximum number of cached items.
Methods¶
TryGet(Int32, Int64, Int64, 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 Int32
x Int64
y Int64
value T&
Returns¶
Get(Int32, Int64, Int64)¶
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 Int32
x Int64
y Int64
Returns¶
T
Add(Int32, Int64, Int64, 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 Int32
x Int64
y Int64
content T
Remove(Int32, Int64, Int64)¶
Removes the specified tile from the cache, if it exists.
public bool Remove(int zoom, long x, long y)
Parameters¶
zoom Int32
x Int64
y Int64
Returns¶
Clear()¶
Removes every cached entry and resets the usage order.
public void Clear()