高速缓存-Caching
Here are the different levels of caching that Orchard can provide:
以下是Orchard可以提供的不同级别的缓存:
Application Settings Cache Using ICacheManager
应用程序设置缓存使用ICacheManager
This is used to store application settings and can be invalidated based on an extensible set of parameters.
这用于存储应用程序设置,并且可以基于可扩展的参数集来使其无效。
By default you find expiration tokens based on time, file system and signals.
默认情况下,您会根据时间,文件系统和信号找到到期令牌。
This is a very powerful caching API but has one drawback: it is not meant to provide farm invalidation,
这是一个非常强大的缓存API,但有一个缺点:它不是为了提供服务器失效,
because it has not been designed for this purpose and should not be used for data which is volatile.
因为它不是为此目的而设计的,不应该用于易变的数据。
Using for settings is totally fine, like for Content Types, module settings, etc. because those values
用于设置是完全正确的,例如内容类型,模块设置等,因为这些值
must not change on a production farm.
不得在生产农场改变。
You never create a content type on production on a farm, or you have to restart all nodes one after the other.
您永远不会在服务器场上的生产中创建内容类型,或者您必须一个接一个地重新启动所有节点。
Another reason to use this module (and why it has been done) is that it is not dependent on memory pressure,
使用此模块的另一个原因(以及为什么要这样做)是它不依赖于内存压力,
so entries won't be removed if your system memory consumption grows, as opposed to the ASP.NET cache.
因此,如果系统内存消耗增加,则不会删除条目,而不是ASP.NET缓存。
All the other cache providers are and must use memory pressure limits.
所有其他缓存提供程序都必须使用内存压力限制。
2nd Level NHibernate Caching
二级NHibernate缓存
This is used to prevent recurring sql queries to the database.
这用于防止对数据库的重复sql查询。
Because the accessors are simple and well defined (checking a string in the dictionary),
因为访问器很简单并且定义良好(检查字典中的字符串),
it's safe to use it on a farm as long as the data is store in a central repository, like using Memcached.
只要数据存储在中央存储库中,就像使用Memcached一样,在农场中使用它是安全的。
A simple Memcached provider for it is tricky as you need to configure the provider (location, port),
一个简单的Memcached提供程序是棘手的,因为您需要配置提供程序(位置,端口),
and usually the settings are best placed in the database, but it's the chicken and egg issue and
通常设置最好放在数据库中,但这是鸡和蛋的问题
you can't bootstrap it from a module. The only solution is then to have the configuration for it inside
你不能从模块中引导它。然后唯一的解决方案就是在里面配置它
the web.config, or maybe the settings.txt when it will be extensible.
web.config,或者它可能是可扩展的settings.txt。
Output Caching Using Contrib.Cache
使用Contrib.Cache输出缓存
The goal of this module is to provide output caching like ASP.NET does, and to provide cache headers
这个模块的目标是像ASP.NET一样提供输出缓存,并提供缓存头
management (max-age, Cache-Control, ETag). It was recently extended to be able to define the storage mechanism
管理(max-age,Cache-Control,ETag)。它最近被扩展为能够定义存储机制
dynamically for the cache data as distributed setups where more widely used.
动态地为缓存数据作为更广泛使用的分布式设置。
This is why there are two distributed storage provider, one based on the Database and the other one based on Memcached.
这就是为什么有两个分布式存储提供程序,一个基于数据库,另一个基于Memcached。
Here is the set of related modules:
这是一组相关的模块:
Not a single Orchard website should go into production without this module.
没有这个模块,没有一个Orchard网站可以投入生产。
Not only does it improve responsiveness but also throughput, and finally it frees your CPU from unneeded cycles.
它不仅提高了响应速度,还提高了吞吐量,最终将CPU从不必要的周期中解放出来。
Using the Max Age setting you also enable IIS Kernel caching plus public proxy cache which makes your application
使用Max Age设置,您还可以启用IIS内核缓存以及生成应用程序的公共代理缓存
even faster. You can get thousands of requests per seconds with a very small server.
甚至更快。使用非常小的服务器,您每秒可以获得数千个请求。
Business Data Caching Using Orchard.Caching
使用Orchard.Caching进行业务数据缓存
Because of the limitations of the ICacheManager in terms of distributed caching, another set of modules was
由于ICacheManager在分布式缓存方面的局限性,另一组模块是
necessary to cache business data which has to be shared across servers.
必须缓存必须在服务器之间共享的业务数据。
This module can set and get entries by a key only, and invalidate by name or time.
此模块只能通过密钥设置和获取条目,并按名称或时间无效。
This is the only requirement for storage providers in this module, which allows its usage on farms.
这是此模块中存储提供程序的唯一要求,允许在服务器场中使用它。
This is implemented in:
这在以下方面实施:
-
https://bitbucket.org/sebastienros/orchard.caching.memcached
-
https://bitbucket.org/sebastienros/orchard.caching.memcached *
Why Memcached ?
为何选择Memcached?
Implementing Memcached providers by default is done for a specific reason, which is that Azure Caching Services
默认情况下,实现Memcached提供程序是出于特定原因,即Azure缓存服务
are binary compatible with it. So this implementation works by default on both custom Memcached servers
是二进制兼容的。因此,此实现默认在两个自定义Memcached服务器上都有效
and also Azure services.
以及Azure服务。