1.Install-Package Microsoft.Extensions.Caching.Redis -Version 2.2.0

2.注入

            services.AddDistributedRedisCache(opt =>
{
opt.Configuration = Configuration.GetConnectionString("RedisServer");
//opt.InstanceName = "db0";
});

3.在Action中读写;

  public ActionResult<string> Get(int id)
{
_distributedCache.SetString("key{id}", JsonConvert.SerializeObject(new object{}));
var obj = JsonConvert.DeserializeObject<object>(_distributedCache.GetStringAsync("key{id}").Result);
return Content(obj.ToString());
}

4.其他构造

【redis】在dotnet core下的redis的使用的更多相关文章

  1. 支付宝AopSdk在dotnet core下的实现

    随着项目都迁移到了dotnet core下,阿里的支付宝也需要随着项目迁移.之前在.Net Framework下用到了阿里提供的AopSdk和F2FPay两个程序集,支付宝官方提供的只支持Framew ...

  2. 【Redis】windows环境下安装redis服务器,并配置php的redis扩展

    win7示例: 1.下载Redis服务器 : https://github.com/dmajkic/redis/downloads:(随便下,建议不要太老的) 2.在D:\phpStudy\ 新建Re ...

  3. linux下redis服务器安装使用 安装php的redis扩展 安装laravel下的redis

    linux下redis服务器安装使用 学习源头: https://blog.csdn.net/itmanba/article/details/77335012 安装完毕试运行redis的时候,可能会出 ...

  4. Redis Windows 64位下安装Redis详细教程

    Windows Redis 下载地址:点击打开链接https://github.com/MicrosoftArchive/redis/releases 点击打开链接 文件介绍 redis-benchm ...

  5. DotNet Core 使用 StackExchange.Redis 简单封装和实现分布式锁

    前言 公司的项目以前一直使用 CSRedis 这个类库来操作 Redis,最近增加了一些新功能,会存储一些比较大的数据,内测的时候发现其中有两台服务器会莫名的报错 Unexpected respons ...

  6. 【redis】在windos下的redis服务器的搭建

    1.下载Redis-x64-3.2.100(楼主用的版本,需要安装包的可以找我要) 下载官方版本 2.解压后在cmd下运行 redis-server redis.windos.conf 此时redis ...

  7. Dotnet Core下的Channel, 你用了吗?

    今天给大家分享一个微软官方的好东西:Channel.   前言 今天给大家分享一个微软官方的生产者/消费者方案的特性解决:Channel. Channel在System.Threading.Chann ...

  8. Net Core 2.0 Redis

    Net Core 2.0 Redis配置.封装帮助类RedisHelper及使用实例 https://www.cnblogs.com/oorz/p/9052498.html 本文目录 摘要 Redis ...

  9. 在Centos 5.6下安装 redis

    先引用redis官方(http://redis.io/) 的介绍: Redis is an open source, advanced key-value store.<br>It is ...

随机推荐

  1. combine_lat_dirs.sh

    #!/bin/bash # Copyright 2018 Jarvan Wang Apache 2.0. # Copyright 2016 Xiaohui Zhang Apache 2.0.     ...

  2. js中对cookie的操作及json数据与cookie结合的用法

    cookie的使用 添加cookie 添加cookie:document.cookie = “key=value”; // 一次写入一个键值对 document.cookie = 'test1=hel ...

  3. 好奇,项目根目录下的.editorconfig文件

    一..editorconfig文件是什么? 在项目里,大多时候都能看到.editorconfig文件,刚开始总是忽视掉它,认为它不太重要.但是,它的存在,必定有它的理由,于是,抽空来研究一下,它是什么 ...

  4. Visual Studio 2013 SDK 扩展之简介

    Release Notes:[发行说明]启动记事本的扩展,以管理员身份运行验证通过. Getting Started Guide:[入门]使用[Ctrl + 1]更快捷打开记事本 More Info ...

  5. Django 连接mysql数据库中文乱码

    Django 连接mysql数据库中文乱码 2018年08月25日 20:55:15 可乐乐乐乐乐 阅读数:566   版本:CentOS6.8 python3.6.4 django1.8.2 数据库 ...

  6. certificate & encryption

    openssl commonly used commands before use Configure to generate Makefile, should notice follow optio ...

  7. html注意事项

    行级元素只能嵌套行级元素 块级元素可以嵌套任何元素 格力  p标签不能嵌套div a标签不能嵌套a标签

  8. vue 部署404

    https://www.cnblogs.com/kevingrace/p/6126762.html 在nginx部署https://www.jianshu.com/p/7017143e3f7a 在ap ...

  9. Centos 7部署docker

    master安装: 安装zookeeper -openjdk java--openjdk-headless rpm -i packages/mesosphere-zookeeper--.centos7 ...

  10. The import javax.servlet.jsp.JspException cannot be resolved

    问题描述   重新更换了 Apache Tomcat 的版本,在 Eclipse 中项目报错信息:The import javax.servlet.jsp.JspException cannot be ...