Table of Contents

Interface ICacheSpecs

Namespace
ToSic.Sxc.Services.Cache
Assembly
ToSic.Sxc.dll

Experimental! Cache Specs which determine how the key is generated, additional dependencies and expiration policies.

[InternalApi_DoNotUse_MayChangeWithoutNotice("WIP v17.09")]
public interface ICacheSpecs

Methods

SetAbsoluteExpiration(DateTimeOffset)

Set absolute expiration, alternative is sliding expiration. If neither are set, a sliding expiration of 1 hour will be used.

ICacheSpecs SetAbsoluteExpiration(DateTimeOffset absoluteExpiration)

Parameters

absoluteExpiration DateTimeOffset

Returns

ICacheSpecs

Remarks

If neither absolute nor sliding are set, a sliding expiration of 1 hour will be used. Setting both is invalid and will throw an exception.

SetSlidingExpiration(TimeSpan)

Set sliding expiration, alternative is absolute expiration.

ICacheSpecs SetSlidingExpiration(TimeSpan slidingExpiration)

Parameters

slidingExpiration TimeSpan

Returns

ICacheSpecs

Remarks

If neither absolute nor sliding are set, a sliding expiration of 1 hour will be used. Setting both is invalid and will throw an exception.

VaryBy(string, string, NoParamOrder, bool)

Vary the cache by a specific name and value. All cache items where this value is the same, will be considered the same. For example, this could be a category name or something where the data for this category is always the same.

ICacheSpecs VaryBy(string name, string value, NoParamOrder protector = default, bool caseSensitive = false)

Parameters

name string
value string
protector NoParamOrder

see Convention: Named Parameters

caseSensitive bool

Returns

ICacheSpecs

VaryByModule(NoParamOrder, ICmsModule, int?)

Vary the cache by module, so that each module has its own cache. By default, it will take the current module, but you can optionally specify a custom module or ID.

ICacheSpecs VaryByModule(NoParamOrder protector = default, ICmsModule module = null, int? id = null)

Parameters

protector NoParamOrder

see Convention: Named Parameters

module ICmsModule

optional module object to use instead of the default

id int?

optional page id to use instead of the default

Returns

ICacheSpecs

VaryByPage(NoParamOrder, ICmsPage, int?)

Vary the cache by page, so that each page has its own cache. By default, it will take the current page, but you can optionally specify a custom page or ID.

ICacheSpecs VaryByPage(NoParamOrder protector = default, ICmsPage page = null, int? id = null)

Parameters

protector NoParamOrder

see Convention: Named Parameters

page ICmsPage

optional page object to use instead of the default

id int?

optional page id to use instead of the default

Returns

ICacheSpecs

VaryByPageParameter(string, NoParamOrder, bool)

Vary the cache by a specific page parameter, eg ?category=1. Using this method will only vary the cache by this specific parameter and ignore the rest.

ICacheSpecs VaryByPageParameter(string name, NoParamOrder protector = default, bool caseSensitive = false)

Parameters

name string

Name of a single parameter

protector NoParamOrder

see Convention: Named Parameters

caseSensitive bool

Determines if the value should be treated case-sensitive, default is false

Returns

ICacheSpecs

VaryByPageParameters(string, NoParamOrder, bool)

ICacheSpecs VaryByPageParameters(string names = null, NoParamOrder protector = default, bool caseSensitive = false)

Parameters

names string
protector NoParamOrder
caseSensitive bool

Returns

ICacheSpecs

VaryByParameters(IParameters, NoParamOrder, string, bool)

Vary the cache by parameters which may not come from the page.

ICacheSpecs VaryByParameters(IParameters parameters, NoParamOrder protector = default, string names = null, bool caseSensitive = false)

Parameters

parameters IParameters

parameters object

protector NoParamOrder

see Convention: Named Parameters

names string

Names of one or more parameters, comma-separated

caseSensitive bool

Determines if the value should be treated case-sensitive, default is false

Returns

ICacheSpecs

VaryByUser(NoParamOrder, ICmsUser, int?)

Vary the cache by user, so that each user has its own cache. By default, it will take the current user, but you can specify a custom user or ID.

ICacheSpecs VaryByUser(NoParamOrder protector = default, ICmsUser user = null, int? id = null)

Parameters

protector NoParamOrder

see Convention: Named Parameters

user ICmsUser

optional module object to use instead of the default

id int?

optional page id to use instead of the default

Returns

ICacheSpecs

WatchAppData(NoParamOrder)

Depend on the app data, so if any data changes, the cache will be invalidated.

ICacheSpecs WatchAppData(NoParamOrder protector = default)

Parameters

protector NoParamOrder

Returns

ICacheSpecs

WatchAppFolder(NoParamOrder, bool?)

Depend on the app folder, so if any file in the app folder changes, the cache will be invalidated. WIP!

ICacheSpecs WatchAppFolder(NoParamOrder protector = default, bool? withSubfolders = null)

Parameters

protector NoParamOrder

see Convention: Named Parameters

withSubfolders bool?

should it also watch subfolders? default is true

Returns

ICacheSpecs