/// <summary> /// Set the specified cacheKey, cacheValue and expiration. /// </summary> /// <returns>The set.</returns> /// <param name="cacheKey">Cache key.</param> /// <param name="cacheValue">Cache value.</param> /// <param name="expiration">Expiration.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void Set <T>(string cacheKey, T cacheValue, TimeSpan expiration) where T : class { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); ArgumentCheck.NotNull(cacheValue, nameof(cacheValue)); ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration)); _memcachedClient.Add(cacheKey, cacheValue, expiration.Seconds); }
public static IApplicationBuilder UseMemcached(this IApplicationBuilder app) { if (MemcachedConfig == null) { return(app); } app.UseEnyimMemcached(); IMemcachedClient client = app.ApplicationServices.GetService <IMemcachedClient>(); if (client.Add("test", "value", 5)) { Console.WriteLine("EnyimMemcachedClient: Connected"); } else { Console.WriteLine("EnyimMemcachedClient: Disconnected"); } return(app); }
public void Set(string key, string value) { _client.Add(key, value, 100); }
public bool Add(string key, object value, int cacheSeconds) { return(_memcachedClient.Add(key, value, cacheSeconds)); }