NamespaceSystemLibrary.Common.Framework.App
Caching for applications
Default duration is 3 minutes
Try using auto-generating cache keys, which differentiate caching down to user roles.- Cache things per user, by userId/email? Create your own cacheKey
'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skipRemarks
Cache is configured to a max capacity of 320.000 items, divided by 8 cache containers, where any item added takes up 1 size
Each container is configured to a max capacity of 40.000 items, once reached 33% of the oldest are removed, ready to be GC'ed
A null value is never added to cacheOverwrite default cache configurations in appsettings.json:
- duration: 180, minimum 1- fallbackDuration: 300, set to 0 or negative to disable fallback cache globally
- containerSizeLimit: 60000, minimum 10Auto-generating cache key adds namespace, class, method, method-scoped variables of types such as bool, string, int, datetime, enum and few others
- If a method-scoped variable is a class, its public members of same types are also appended as cacheKey
- IsAuthenticated is always appended to cacheKey- Claim 'role', 'Role' and RoleClaimType if found, is always appended to cacheKey
- Always adds built-in prefixCache
public static class Cache
Inheritance
Methods
Remarks
Only entries set through either TryGet, Get or Set will be cleared
- other cache mechanisms that you are using are not touched
Clearing cache is not thread safe as it null's out the cache containers and recreates them all- null checks exists before the cache containers are used, but it does not gurantee thread safety
Remarks
A null value is never added to cache
Throws exception if getItem can throwDefault duration is 200 seconds
'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skipRemarks
A null value is never added to cache
Throws exception if getItem can throwDefault duration is 200 seconds
'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skipRemarks
CacheKey null or blank returns default without checking cache
This never checks fallback cache
Remarks
A null value is never added to cache
Throws exception if getItem can throwDefault duration is 200 seconds
'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skipRemarks
Uses the stack frame to read current namespace and method as cache key, so max 1 invocation per function scope, else you must fill out the breakKey parameter too
- in the future it might support multiple...
Multiple threads running at same time, will trigger this multiple times as we do not really 'lock'
Remarks
A null value is never added to cache
Default duration is 200 seconds'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skipRemarks
A null value is never added to cache
Default duration is 200 seconds'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skipRemarks
A null value is never added to cache
Default duration is 200 seconds'Ignore' means the function will always be invoked directly, bypassing the cache entirely.
Skip options:- skipWhenAuthenticated, false by default
- skipWhenAdmin, true by defaultThe user must belong to one of the following case-sensitive roles: Admin, Admins, Administrator, Administrators, WebAdmins, CmsAdmins, admin, admins, administrator, administrators.
- skipWhen, your own condition, must return True to skip}