示例#1
0
        public async Task <LogResultModel> Log(string token, object data)
        {
            var            encodedVallue = Base64Utility.Encode(token.ToString());
            LogResultModel result        = await base.Post <LogResultModel>("log", encodedVallue, data);

            return(result);
        }
示例#2
0
        public async Task <AuthResultModel> Authenticate(string token)
        {
            var             encodedVallue = Base64Utility.Encode(token.ToString());
            AuthResultModel result        = await base.Post <AuthResultModel>("auth", encodedVallue, null);

            return(result);
        }
        private string CompressContent(object content)
        {
            var serializedContent = JsonConvert.SerializeObject(content);
            var compressedContent = Base64Utility.Encode(serializedContent);

            return(compressedContent);
        }
        public void Set(string key, object content)
        {
            var cacheKey          = Base64Utility.Encode(key);
            var compressedContent = CompressContent(content);

            _cache.Set(cacheKey, compressedContent, TimeSpan.FromMinutes(_config.Expiration));
        }
        public bool TryGet <T>(string key, out T content)
        {
            var cacheKey = Base64Utility.Encode(key);

            if (!_cache.TryGetValue(cacheKey, out string compressedContent))
            {
                content = default(T);
                return(false);
            }

            content = DecompressContent <T>(compressedContent);
            return(true);
        }