我的NopCommerce之旅(5): 缓存
一、基础介绍
二、NopCommerce的缓存分析
//cache managers
if (config.RedisCachingEnabled)
{
builder.RegisterType<RedisCacheManager>().As<ICacheManager>().Named<ICacheManager>("nop_cache_static").InstancePerLifetimeScope();
}
else
{
builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().Named<ICacheManager>("nop_cache_static").SingleInstance();
}
2.2.RedisCachingEnabled通过读取配置文件,见Nop.Core.Configuration.NopConfig
var redisCachingNode = section.SelectSingleNode("RedisCaching");
if (redisCachingNode != null && redisCachingNode.Attributes != null)
{
var enabledAttribute = redisCachingNode.Attributes["Enabled"];
if (enabledAttribute != null)
config.RedisCachingEnabled = Convert.ToBoolean(enabledAttribute.Value); var connectionStringAttribute = redisCachingNode.Attributes["ConnectionString"];
if (connectionStringAttribute != null)
config.RedisCachingConnectionString = connectionStringAttribute.Value;
}
3.应用
[NonAction]
protected virtual List<int> GetChildCategoryIds(int parentCategoryId)
{
string cacheKey = string.Format(ModelCacheEventConsumer.CATEGORY_CHILD_IDENTIFIERS_MODEL_KEY,
parentCategoryId,
string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()),
_storeContext.CurrentStore.Id);
return _cacheManager.Get(cacheKey, () =>
{
var categoriesIds = new List<int>();
var categories = _categoryService.GetAllCategoriesByParentCategoryId(parentCategoryId);
foreach (var category in categories)
{
categoriesIds.Add(category.Id);
categoriesIds.AddRange(GetChildCategoryIds(category.Id));
}
return categoriesIds;
});
}
我的NopCommerce之旅(5): 缓存的更多相关文章
- 我的NopCommerce之旅(8): 路由分析
一.导图和基础介绍 本文主要介绍NopCommerce的路由机制,网上有一篇不错的文章,有兴趣的可以看看NopCommerce源码架构详解--对seo友好Url的路由机制实现源码分析 SEO,Sear ...
- [转]NopCommerce之旅: 应用启动
本文转自:http://www.cnblogs.com/devilsky/p/5359881.html 我的NopCommerce之旅(6): 应用启动 一.基础介绍 Global.asax 文件 ...
- 我的NopCommerce之旅(7): 依赖注入(IOC/DI)
一.基础介绍 依赖注入,Dependency Injection,权威解释及说明请自己查阅资料. 这里简单说一下常见使用:在mvc的controller的构造方法中定义参数,如ICountryServ ...
- 我的NopCommerce之旅(9): 编写Plugin实例
一.基础介绍 ——In computing, a plug-in (or plugin) is a set of software components that add specific abili ...
- 我的NopCommerce之旅(3): 系统代码结构分析
一.概述 基于MVC 二.详细描述 \Libraries\Nop.Core 核心类,包括缓存.事件.帮助类.业务对象(订单.客户实体) \Libraries\Nop.Data 数据访问层,采用Enti ...
- 我的NopCommerce之旅(1): 系统综述
一.概述 NopCommerce是一个开源的购物网站,它的特点是Pluggable modular/layered architecture(可插拔模块分层架构) 二.功能特色介绍 1.适配手机端 2 ...
- 我的NopCommerce之旅(6): 应用启动
一.基础介绍 Global.asax 文件(也称为 ASP.NET 应用程序文件)是一个可选文件,该文件包含响应 ASP.NET 或 HTTP 模块所引发的应用程序级别和会话级别事件的代码. Appl ...
- 我的NopCommerce之旅(4): 定时任务之邮件
一.功能简介 用户购买物品生成订单后,系统将发送邮件提醒给用户 二.操作步骤 后台配置一个系统的默认发送邮箱 启动定时任务,这里包括多个任务,只需要启动邮件任务 查看邮件发送情况 三.数据库分析 [d ...
- 我的NopCommerce之旅(2): 系统环境及技术分析
一.系统环境 IIS7.0 or above ASP.NET 4.5(MVC 5.0) .NET Framework 4.5.1 or above VS 2012 or above 二.架构设计 Pl ...
随机推荐
- Jquery 获取所有对象的第一个子元素
转自:http://blog.sina.com.cn/s/blog_5fdbd0410100pmnn.html <ul> <li>John</li> <l ...
- 使用boost库生成 随机数 随机字符串
#include <iostream> #include <boost/random/random_device.hpp> #include "boost/rando ...
- codevs 2102 石子归并2
传送门 2102 石子归并 2 时间限制: 10 s 空间限制: 256000 KB 题目等级 : 黄金 Gold 题目描述 Description 在一个园形操场的四周摆放N堆石子,现要将 ...
- saltstack master minion安装配置简单使用
首先先了解下saltstack是什么,为什么使用它 它与Ansible.Puppet都属于集中管理工具,由于现在企业规模的不断庞大及业务的增长,所需要管理的服务器数量增多,而且大部分机器都属于同类业务 ...
- bzoj2159
树形dp+第二类斯特林数 又是这种形式,只不过这次不用伯努利数了 直接搞肯定不行,我们化简一下式子,考虑x^n的组合意义,是把n个物品放到x个箱子里的方案数.那么就等于这个i=1->n,sigm ...
- 二、myeclipse中配置mybatis中xml的自动提示
以mybatis中mapper.xml为例 方法一: 步骤一:在mybatis-3.3.0.jar包中寻找mybatis-3-mapper.dtd文件. 可以用360压缩打开mybatis-3.3.0 ...
- Summit Online Judge
题意: 询问将取值在 $[L,R]$ 的若干个整数相加,可以得到 $[x,y]$ 区间内多少个数字. 解法: 只需要考虑求 $[L,R]$ 的数字能凑出 $[1,n]$ 的多少个数字,即可得出答案. ...
- 【网络爬虫】【python】网络爬虫(四):scrapy爬虫框架(架构、win/linux安装、文件结构)
scrapy框架的学习,目前个人觉得比较详尽的资料主要有两个: 1.官方教程文档.scrapy的github wiki: 2.一个很好的scrapy中文文档:http://scrapy-chs.rea ...
- Eclipse 安装Maven插件
这个好: http://www.iteye.com/topic/1123225 其他: 1先安装subeclipse插件就是svn svn - http://subclipse.tigris.org/ ...
- 51nod - 1363 - 最小公倍数之和 - 数论
https://www.51nod.com/Challenge/Problem.html#!#problemId=1363 求\(\sum\limits_{i=1}^{n}lcm(i,n)\) 先换成 ...