public IEnumerable <Translation> GetAll() { var translations = _keyValueCache.Get(CacheKey); if (translations == null) { _keyValueCache.Add(CacheKey, _session.Query <Translation>().ToList()); } return(_keyValueCache.Get(CacheKey)); }
public IHttpActionResult Post([FromBody] Input value) { double expiryTime; try { if (value == null) { return(BadRequest()); } else { if (value.expiryTime != null) { double.TryParse(value.expiryTime.ToString(), out expiryTime); if (_keyValueCache.Add(value.key, value.value, expiryTime)) { long expiresAt = DateTimeOffset.Now.AddSeconds(expiryTime).ToUnixTimeSeconds(); return(Ok(new JObject( new JProperty("expiresAt", expiresAt) ))); } return(InternalServerError()); } else { return(Ok(new JObject( new JProperty("expiresAt", null) ))); } } } catch (Exception ex) { Console.WriteLine("CacheController.Post " + ex); return(InternalServerError()); } }