ABP Source Code Analysis 13: Caching Cache implementation

Source: Internet
Author: User

AbpThere are two types ofCacheThe implementation method:MemroycacheAndRediscache.For example, both are inherited toICacheInterface (it is accurate to say thatcachebase abstract Class). abp Core module encapsulates memroycache abp Abp.rediscache This module encapsulates rediscache To implement the cache (via stackexchange.redis This class library access redis).

ICache : The cached interface. The value of type object is cached as a key of type string. The Icache.get method has two parameters:

key: The unique string key for an entry in the cache.

• Factory: Call the action to create the cache without locating the cached entry for the given key. The factory method should create and return the actual entries. if the given key is found in the cache, the action is not invoked.

The Icache interface also has a method like getordefault,set,remove,clear. At the same time, these methods also have asynchronous (async) versions.

Itypedcache/Typedcachewrapper: support generics key and value cache interface and implementation, its internal through encapsulation icache object implementation. by cacheextension The method can be conveniently icache< Span style= "font-family: Microsoft Jas Black;" lang= "ZH-CN" > object converted to itypedcache object.

The Itypecache is a Icache wrapper that provides a type-safe, generic cache. To convert Icache to Itypedcache, we can use the astyped extension method

cacheextension , encapsulating the extension method of the ICache .

Abpcachenames : defines the key constants for four caches , which are used by the ABP framework

Icacheconfigurator /cacheconfigurator: Encapsulates the name of the cache and the initialization method for the CAHCE, which can be done by initializing the Cache configuration (such as expiration Time).

&NBSP;

icachingconfiguration /cachingconfiguration: This interface provides a way to complete the configuration of the cache. Specifically, the cache is configured by encapsulating a Icacheconfigurator collection and calling the initaction above it .

Icachemanager/cachemanagerbase : The interface and implementation are used to generate, configure and destroy icache instance. Specifically through icachingconfiguration cache, Span style= "font-family: Microsoft Jas Black;" lang= "ZH-CN" > and through concurrentdictionary<string, Icache> to store and manage cache.

The Icachemanager.getcache method returns a Icache. The cache is created the first time it is requested, and the same cached object is returned later. Therefore, we can share the same cache with the same name in different classes (clients).

Abpmemorycache : implements Icache through the CLR's memorycache .

 

abpm Emorycachemanager : Rewritten cachemanagerbasecreatecacheimplementation Icache object. concrete to abpmemorycachemanagerabpmemorycache

ABP Source Code Analysis 13: Caching Cache implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.