Search Results for

    Show / Hide Table of Contents

    Class TileDrawableCache

    Drawable cache for tile layers with LRU-style eviction based on render iteration. Keeps more tiles than strictly needed so that zooming in/out doesn't immediately discard previously rendered tiles.

    Inheritance
    object
    TileDrawableCache
    Implements
    IDrawableCache
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Mapsui.Rendering
    Assembly: Mapsui.dll
    Syntax
    public sealed class TileDrawableCache : IDrawableCache, IDisposable

    Methods

    | Edit this page View Source

    Cleanup(long)

    Evicts stale cache entries. The exact strategy depends on the implementation:

    • DrawableCache: removes everything not stamped with currentIteration.
    • TileDrawableCache: keeps a number of extra tiles and removes the oldest by iteration.
    Declaration
    public void Cleanup(long currentIteration)
    Parameters
    Type Name Description
    long currentIteration
    Remarks

    LRU cleanup: counts the tiles stamped with currentIteration as "active", then keeps up to 3× active (minimum 256) total entries. Excess entries are removed oldest-iteration-first.

    | Edit this page View Source

    Clear()

    Clears all cached entries and disposes them.

    Declaration
    public void Clear()
    | Edit this page View Source

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    | Edit this page View Source

    Get(DrawableCacheKey, long)

    Gets the drawable for a (feature, style) combination, or null if not cached. Stamps the entry with iteration so that Cleanup(long) knows the entry is still in use.

    Declaration
    public IDrawable? Get(DrawableCacheKey key, long iteration)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key of feature and style GenerationIds.

    long iteration

    The current render iteration.

    Returns
    Type Description
    IDrawable
    | Edit this page View Source

    ReleaseReservation(DrawableCacheKey)

    Releases a reservation previously acquired via TryReserve(DrawableCacheKey). Call this in a finally block after creation completes (success or failure).

    Declaration
    public void ReleaseReservation(DrawableCacheKey key)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key to release.

    | Edit this page View Source

    Set(DrawableCacheKey, IDrawable, long)

    Stores a drawable for a (feature, style) combination. GenerationIds are immutable — each combination is only ever set once. If the entry already exists it is not replaced. The entry is stamped with iteration.

    Declaration
    public void Set(DrawableCacheKey key, IDrawable drawable, long iteration)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key of feature and style GenerationIds.

    IDrawable drawable

    The drawable to cache.

    long iteration

    The current render iteration.

    | Edit this page View Source

    TryReserve(DrawableCacheKey)

    Attempts to reserve a key for creation. If the key is already reserved by another thread (creation in progress) or already exists in the cache, returns false. Use this before creating an expensive drawable to avoid duplicate work.

    Declaration
    public bool TryReserve(DrawableCacheKey key)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key of feature and style GenerationIds.

    Returns
    Type Description
    bool

    True if the reservation was successful; false if already reserved or cached.

    Implements

    IDrawableCache
    IDisposable

    Extension Methods

    DisposableExtension.DisposeIfDisposable(object?)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX