社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Redis

RedisServerException:运行脚本时出错

Berkay Kulak • 3 年前 • 818 次点击  

我正在连接redis服务器。然后说redis服务器。我正在用redis cli启动客户端。我有自己的MVC项目。产品控制器是这样的

public class ProductsController : Controller
    {
        private readonly IDistributedCache _distributedCache;

        public ProductsController(IDistributedCache distributedCache)
        {
            _distributedCache = distributedCache;
        }

        public IActionResult Index()
        {
            DistributedCacheEntryOptions cacheEntryOptions = new DistributedCacheEntryOptions();

            cacheEntryOptions.AbsoluteExpiration = DateTime.Now.AddMinutes(1);

            _distributedCache.SetString("name","Berkay",cacheEntryOptions);


            return View();
        }
    }

针对持有错误类型值的键的错误类型操作 错误就在这里。

_distributedCache.SetString("name","Berkay",cacheEntryOptions);

另外,我的启动文件如下所示。我也在ConfigureService中做了定义

 public void ConfigureServices(IServiceCollection services)
        {
            services.AddStackExchangeRedisCache(opt =>
            {
                opt.Configuration = "localhost:6379";
            });

            services.AddControllersWithViews();
        }
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129203
 
818 次点击  
文章 [ 1 ]  |  最新文章 3 年前