惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Vercel News
Vercel News
L
LangChain Blog
B
Blog RSS Feed
Y
Y Combinator Blog
IT之家
IT之家
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
V
V2EX
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
阮一峰的网络日志
阮一峰的网络日志
有赞技术团队
有赞技术团队
D
Docker
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
月光博客
月光博客

博客园 - HUGO.CM

安装OpenCode后,无法使用。解决方案 修改Abp中Auto API Controllers中 默认生成的 Put、Delete请求 vs2022 开发Python 中文报错:SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte Abp9.0.4运行DbMigrator,报错“The LINQ expression '@__organizationUnitIds_0' could not be translated. ...” 执行abp命令时,出现死循环解决方案 ABP与BootstrapBlazor 本地化相关处理 【机译】ABP Helper Methods Blazor文件上传异常:Did not receive any data in the allotted time Abp报错:AbpException: No theme registered! Use AbpThemingOptions to register themes. Abp vNext 在控制台输出SQL 【译】在 ABP 框架项目中配置多个数据库上下文 ABP浏览页面报错:Could not find the bundle file '/libs/abp/core/abp.css' for the bundle 'LeptonXLite.Global' 或 'Basic.Global' 运行abp install-libs再报错npm ERR! code E404 Abp配置文件设置IdentityServer客户端 精简版Abp开发教程 - 第三章: 创建应用程序 精简版Abp开发教程 - 第二章: 创建实体与数据库 精简版Abp开发教程 - 第一章: 创建解决方案 Abp vNext 使用Mysql数据库 Abp vNext 修改默认表前缀 Abp vNext 使用sql2005、sql2008等脚本报错解决
Abp分布式实体缓存
HUGO.CM · 2022-11-30 · via 博客园 - HUGO.CM

直接缓存实体对象

  1. 注册实体缓存:.context.Services.AddEntityCache<Product, Guid>()
  2. 注入和使用.IEntityCache<Product, Guid>服务

使用此用法,实体类应可序列化/可序列化为 JSON/可从 JSON 反序列化。

实体映射到缓存项

  1. 定义缓存类,例如:ProductCacheItem
  2. 对象映射配置:Product->ProductCacheItem
  3. 注册实体缓存:.context.Services.AddEntityCache<Product, ProductCacheItem, Guid>()
  4. 注入和使用.IEntityCache<ProductCacheItem, Guid>服务

使用上下文化对象映射器

只有使用最佳实践指南构建的可重用模块才需要这样做。应用程序开发人员不需要它。

  1. 定义缓存类,例如:ProductCacheItem
  2. 对象映射配置:Product->ProductCacheItem
  3. 注册实体缓存:.*context.Services.AddEntityCache<TMyModule, Product, ProductCacheItem, Guid>()
  4. 注入和使用.IEntityCache<ProductCacheItem, Guid>服务
    *TMyModule 是我们定义对象映射器上下文的模块类的类型。

其他说明

  • 所有context.Services.AddEntityCache()方法都获得一个可选的DistributedCacheEntryOptions,在这里您可以轻松地配置选项。默认值为:
new DistributedCacheEntryOptions {
    AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(2)
}
  • 实体缓存专为只读而设计。使用实体缓存时,我们不应对同一实体进行更改。如果我们需要更改实体,我们应该从数据库中读取它,以确保事务一致性。