diff --git a/Enyim.Caching/Enyim.Caching.csproj b/Enyim.Caching/Enyim.Caching.csproj index 6cdfecc9..12ef1c32 100755 --- a/Enyim.Caching/Enyim.Caching.csproj +++ b/Enyim.Caching/Enyim.Caching.csproj @@ -2,7 +2,7 @@ EnyimMemcachedCore is a Memcached client library for .NET Core. Usage: Add services.AddEnyimMemcached(...) and app.UseEnyimMemcached() in Startup. Add IMemcachedClient into constructor. - 2.1.0 + 2.1.0.1 cnblogs.com netstandard2.0 true diff --git a/Enyim.Caching/IMemcachedClient.cs b/Enyim.Caching/IMemcachedClient.cs index 136780c0..1aebbfeb 100644 --- a/Enyim.Caching/IMemcachedClient.cs +++ b/Enyim.Caching/IMemcachedClient.cs @@ -11,6 +11,9 @@ public interface IMemcachedClient : IDisposable void Add(string key, object value, int cacheSeconds); Task AddAsync(string key, object value, int cacheSeconds); + void Set(string key, object value, int cacheSeconds); + Task SetAsync(string key, object value, int cacheSeconds); + Task> GetAsync(string key); Task GetValueAsync(string key); object Get(string key); diff --git a/Enyim.Caching/MemcachedClient.cs b/Enyim.Caching/MemcachedClient.cs index 000b2403..64aa05f7 100755 --- a/Enyim.Caching/MemcachedClient.cs +++ b/Enyim.Caching/MemcachedClient.cs @@ -98,6 +98,16 @@ public async Task AddAsync(string key, object value, int cacheSeconds) await StoreAsync(StoreMode.Add, key, value, new TimeSpan(0, 0, cacheSeconds)); } + public void Set(string key, object value, int cacheSeconds) + { + Store(StoreMode.Set, key, value, new TimeSpan(0, 0, cacheSeconds)); + } + + public async Task SetAsync(string key, object value, int cacheSeconds) + { + await StoreAsync(StoreMode.Set, key, value, new TimeSpan(0, 0, cacheSeconds)); + } + /// /// Retrieves the specified item from the cache. /// diff --git a/Enyim.Caching/NullMemcachedClient.cs b/Enyim.Caching/NullMemcachedClient.cs index b252836c..cdfc2744 100644 --- a/Enyim.Caching/NullMemcachedClient.cs +++ b/Enyim.Caching/NullMemcachedClient.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using Enyim.Caching.Memcached; @@ -40,37 +41,37 @@ public CasResult Cas(StoreMode mode, string key, object value, TimeSpan va public CasResult Cas(StoreMode mode, string key, object value, DateTime expiresAt, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public ulong Decrement(string key, ulong defaultValue, ulong delta) { - throw new NotImplementedException(); + return default(ulong); } public ulong Decrement(string key, ulong defaultValue, ulong delta, TimeSpan validFor) { - throw new NotImplementedException(); + return default(ulong); } public CasResult Decrement(string key, ulong defaultValue, ulong delta, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public ulong Decrement(string key, ulong defaultValue, ulong delta, DateTime expiresAt) { - throw new NotImplementedException(); + return default(ulong); } public CasResult Decrement(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public CasResult Decrement(string key, ulong defaultValue, ulong delta, DateTime expiresAt, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public void Dispose() @@ -118,57 +119,57 @@ public async Task GetValueAsync(string key) public IDictionary> GetWithCas(IEnumerable keys) { - throw new NotImplementedException(); + return new Dictionary>(); } public CasResult GetWithCas(string key) { - throw new NotImplementedException(); + return new CasResult(); } public CasResult GetWithCas(string key) { - throw new NotImplementedException(); + return new CasResult(); } public ulong Increment(string key, ulong defaultValue, ulong delta) { - throw new NotImplementedException(); + return default(ulong); } public ulong Increment(string key, ulong defaultValue, ulong delta, TimeSpan validFor) { - throw new NotImplementedException(); + return default(ulong); } public CasResult Increment(string key, ulong defaultValue, ulong delta, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public ulong Increment(string key, ulong defaultValue, ulong delta, DateTime expiresAt) { - throw new NotImplementedException(); + return default(ulong); } public CasResult Increment(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public CasResult Increment(string key, ulong defaultValue, ulong delta, DateTime expiresAt, ulong cas) { - throw new NotImplementedException(); + return new CasResult(); } public bool Prepend(string key, ArraySegment data) { - throw new NotImplementedException(); + return false; } public CasResult Prepend(string key, ulong cas, ArraySegment data) { - throw new NotImplementedException(); + return new CasResult(); } public bool Remove(string key) @@ -176,14 +177,14 @@ public bool Remove(string key) return true; } - public async Task RemoveAsync(string key) + public Task RemoveAsync(string key) { - return true; + return Task.FromResult(false); } public ServerStats Stats() { - throw new NotImplementedException(); + return new ServerStats(new Dictionary>()); } public ServerStats Stats(string type) @@ -218,20 +219,33 @@ public bool Store(StoreMode mode, string key, object value, DateTime expiresAt) public bool TryGet(string key, out object value) { - throw new NotImplementedException(); + value = null; + return false; } public bool TryGetWithCas(string key, out CasResult value) { - throw new NotImplementedException(); + value = new CasResult(); + return false; } public void Add(string key, object value, int cacheSeconds) { } - public async Task AddAsync(string key, object value, int cacheSeconds) + public Task AddAsync(string key, object value, int cacheSeconds) + { + return Task.CompletedTask; + } + + public void Set(string key, object value, int cacheSeconds) + { + + } + + public Task SetAsync(string key, object value, int cacheSeconds) { + return Task.CompletedTask; } } }