Table of Contents

Class IHasPiggyBackExtensions

Namespace
ToSic.Sys.Caching.PiggyBack
Assembly
ToSic.Sys.Caching.dll
[InternalApi_DoNotUse_MayChangeWithoutNotice]
public static class IHasPiggyBackExtensions
Inheritance
object
IHasPiggyBackExtensions

Methods

PiggyBackGetExpiring<TData>(IHasPiggyBack, ITimestamped, string, Func<TData>)

Get a value from the Piggyback or create it. Will expire if the parent is updated.

public static (TData Value, bool IsCached) PiggyBackGetExpiring<TData>(this IHasPiggyBack parent, ITimestamped expiring, string key, Func<TData> create)

Parameters

parent IHasPiggyBack
expiring ITimestamped

Parent object with timestamp.

key string

Key to use in the caching dictionary, should be unique for the expected use case.

create Func<TData>

Generator function

Returns

(TData Value, bool IsCached)

Type Parameters

TData

Remarks

Use this to piggy-back data which may need to expire if the parent changes. If the parent is timestamped

PiggyBackGetExpiring<TPiggyBack, TData>(TPiggyBack, Func<TData>, string?, string?)

Get PiggyBack property using automatic name. Will auto-expire if the app has any changes on it. Uses the caller object name and method for the key.

public static (TData Value, bool IsCached) PiggyBackGetExpiring<TPiggyBack, TData>(this TPiggyBack parent, Func<TData> create, string? cPath = null, string? cName = null) where TPiggyBack : IHasPiggyBack, ITimestamped

Parameters

parent TPiggyBack

Parent with Piggy-Back and timestamp information

create Func<TData>
cPath string

auto

cName string

auto

Returns

(TData Value, bool IsCached)

Type Parameters

TPiggyBack
TData

PiggyBackGetExpiring<TPiggyBack, TData>(TPiggyBack, string, Func<TData>)

Get from piggyback, while using the parent as the cache/expiring parameter to ensure reload when app changes

public static (TData Value, bool IsCached) PiggyBackGetExpiring<TPiggyBack, TData>(this TPiggyBack parent, string key, Func<TData> create) where TPiggyBack : IHasPiggyBack, ITimestamped

Parameters

parent TPiggyBack

Parent with Piggy-Back and timestamp information

key string
create Func<TData>

Returns

(TData Value, bool IsCached)

Type Parameters

TPiggyBack
TData

PiggyBackGet<TData>(IHasPiggyBack, string, Func<TData>)

Get a piggybacked value from the parent, or create it if it doesn't exist.

[InternalApi_DoNotUse_MayChangeWithoutNotice]
public static TData PiggyBackGet<TData>(this IHasPiggyBack parent, string key, Func<TData> create)

Parameters

parent IHasPiggyBack
key string
create Func<TData>

Returns

TData

Type Parameters

TData

PiggyBackRemove(IHasPiggyBack, string)

Remove a piggybacked value from the parent.

public static void PiggyBackRemove(this IHasPiggyBack parent, string key)

Parameters

parent IHasPiggyBack
key string