zoukankan      html  css  js  c++  java
  • net core2 采坑-- session 缓存

    引用 Microsoft.Extensions.Caching.SqlServer 可以设置存在数据库

    Microsoft.Extensions.Caching.Redis 存在redis

    参考 

    http://www.cnblogs.com/hantianwei/p/5723959.html

    // Microsoft SQL Server implementation of IDistributedCache.
    // Note that this would require setting up the session state database.
    services.AddDistributedSqlServerCache(o =>
    {
    o.ConnectionString = "Server=.;Database=ASPNET5SessionState;Trusted_Connection=True;";
    o.SchemaName = "dbo";
    o.TableName = "Sessions";
    });

    数据库表 结构:

    CREATE TABLE [dbo].[CacheTable](
        [Id] [nvarchar](449) NOT NULL,
        [Value] [varbinary](max) NOT NULL,
        [ExpiresAtTime] [datetimeoffset](7) NOT NULL,
        [SlidingExpirationInSeconds] [bigint] NULL,
        [AbsoluteExpiration] [datetimeoffset](7) NULL,
     CONSTRAINT [pk_Id] PRIMARY KEY CLUSTERED 
    (
        [Id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
     
          
    IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
     
          
    ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON
    [PRIMARY]

    CREATE NONCLUSTERED INDEX [Index_ExpiresAtTime] ON [dbo].[CacheTable]
    (
        [ExpiresAtTime] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
     
          
    SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF,
     
          
    ONLINE = OFF, ALLOW_ROW_LOCKS = ON,
     
          
    ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    参考: http://gunnarpeipman.com/2017/04/aspnet-core-sql-server-cache/

    老外还是很靠谱
  • 相关阅读:
    ABP 源码分析目录
    vika维格表模板大赛落幕:3888元大礼包花落谁家?
    OKR太难定?模板大全:产品/研发/运营/销售/行政全都有
    菜鸟成长记(四)----- 实习总结与反思
    菜鸟成长记(三)----- 年终总结与感悟
    菜鸟成长记(二)
    自我激励
    承认
    书评-《当下的力量(珍藏版)》-埃克哈特·托利
    关于吃苦
  • 原文地址:https://www.cnblogs.com/zxs-onestar/p/7538245.html
Copyright © 2011-2022 走看看