Exemplo n.º 1
0
        private string TryGetSessionIdAsync(bool?newSession, string userHash)
        {
            var cacheKey = GetSessionCacheKey(userHash);

            _cache.TryGet(cacheKey, out string sessionId);

            if (newSession == true || string.IsNullOrEmpty(sessionId))
            {
                sessionId = Guid.NewGuid().ToString("N");

                _cache.AddAsync(cacheKey, sessionId, TimeSpan.FromMinutes(5)).Forget();
            }

            return(sessionId);
        }
Exemplo n.º 2
0
        protected override async Task <OutputModel> AfterAsync(InputModel input, Models.Response response)
        {
            var output = await base.AfterAsync(input, response);

            _mapper.Map(input, output);

            output.AddToUserState(Models.Request.IsOldUserKey, true);

            output.AddToUserState(Models.Response.NextTextIndexStorageKey, response.NextTextIndex);

            output.AddToSessionState(Models.Response.ScopeStorageKey, response.ScopeKey);

            _cache.AddAsync($"marusia:{response.UserHash}", string.Empty, TimeSpan.FromDays(14)).Forget();

            return(output);
        }
        public void Add(string invocationKey, string scopeId)
        {
            var cacheKey = GetCacheKey(invocationKey);

            _cache.AddAsync(cacheKey, scopeId, _expiration).Forget();
        }