コード例 #1
0
        public IActionResult InsertRedis([FromBody] TstModel model)
        {
            var db = _redisProvider.GetMultiplexer().GetDatabase();

            var entries = new HashEntry[] {
                new HashEntry("Role", model.Role),
                new HashEntry("Password", model.Password)
            };

            try
            {
                db.HashSet(model.Login, entries);
            }
            catch (Exception)
            {
                throw;
            }


            return(Ok());
        }
コード例 #2
0
 public async Task AddTokenAsync(RefreshToken token, string role)
 {
     var db            = _redisProvider.GetMultiplexer().GetDatabase();
     var ticksToExpire = (token.ExpirationDate - DateTime.Now).Ticks;
     await db.StringSetAsync(token.TokenValue, role, new TimeSpan(ticksToExpire));
 }