Class CacheAllStreams
- Namespace
- ToSic.Eav.DataSources.Caching
- Assembly
- ToSic.Eav.DataSources.dll
Special DataSource which automatically caches everything it's given.
It's Used to optimize queries, so that heavier calculations don't need to be repeated if another request with the same signature is used.
Internally it asks all up-stream DataSources what factors would determine their caching.
So if part of the supplying DataSources would have a changed parameter (like a different filter), it will still run the full query and cache the results again.
[VisualQuery(NiceName = "Cache Streams", UiHint = "Cache all streams based on some rules", Icon = "history_toggle_off", Type = DataSourceType.Cache, NameId = "ToSic.Eav.DataSources.Caching.CacheAllStreams, ToSic.Eav.DataSources", DynamicIn = true, DynamicOut = true, OutMode = "mirror-in", ConfigurationType = "|Config ToSic.Eav.DataSources.Caches.CacheAllStreams", NameIds = new string[] { "ToSic.Eav.DataSources.Caches.CacheAllStreams, ToSic.Eav.DataSources" }, HelpLink = "https://github.com/2sic/2sxc/wiki/DotNet-DataSource-CacheAllStreams")]
[PublicApi]
public class CacheAllStreams : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheKey, ICacheExpiring, ITimestamped, IHasLog, IDataSourceLinkable
- Inheritance
-
objectCacheAllStreams
- Implements
- Inherited Members
Remarks
- Changed in v15.05 to use the immutable convention
- note that the above change is actually a breaking change, but since this is such an advanced DataSource, we assume it's not used in dynamic code.
Properties
CacheDurationInSeconds
How long to keep these streams in the cache.
Default is 0
- meaning fall back to 1 day
[Configuration(Fallback = 0, CacheRelevant = false)]
public int CacheDurationInSeconds { get; }
Property Value
CacheErrorDurationInSeconds
Special cache duration for streams returning an error.
Default to 0
. Possible values:
0
cache for 3 times as-long-as-it-takes to generate source data (delay retry on slow source)-1
don't cache at all and retry immediately- any other number: cache longer, e.g. if the source needs long to generate.
[Configuration(Fallback = 0, CacheRelevant = false)]
public int CacheErrorDurationInSeconds { get; }
Property Value
Out
Gets the Dictionary of Out-Streams. This is the internal accessor, as usually you'll use this["name"] instead.
In rare cases you need the Out, for example to list the stream names in the data source.
public override IReadOnlyDictionary<string, IDataStream> Out { get; }
Property Value
- IReadOnlyDictionary<string, IDataStream>
A dictionary of named IDataStream objects, case insensitive
RefreshOnSourceRefresh
If a source-refresh should trigger a cache rebuild
[Configuration(Fallback = true, CacheRelevant = false)]
public bool RefreshOnSourceRefresh { get; }