Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Enyim.Caching/Enyim.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>EnyimMemcachedCore is a Memcached client library for .NET Core. Usage: Add services.AddEnyimMemcached(...) and app.UseEnyimMemcached() in Startup. Add IMemcachedClient into constructor.</Description>
<VersionPrefix>2.1.0</VersionPrefix>
<VersionPrefix>2.1.0.1</VersionPrefix>
<Authors>cnblogs.com</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
3 changes: 3 additions & 0 deletions Enyim.Caching/IMemcachedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IGetOperationResult<T>> GetAsync<T>(string key);
Task<T> GetValueAsync<T>(string key);
object Get(string key);
Expand Down
10 changes: 10 additions & 0 deletions Enyim.Caching/MemcachedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/// <summary>
/// Retrieves the specified item from the cache.
/// </summary>
Expand Down
62 changes: 38 additions & 24 deletions Enyim.Caching/NullMemcachedClient.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -40,37 +41,37 @@ public CasResult<bool> Cas(StoreMode mode, string key, object value, TimeSpan va

public CasResult<bool> Cas(StoreMode mode, string key, object value, DateTime expiresAt, ulong cas)
{
throw new NotImplementedException();
return new CasResult<bool>();
}

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<ulong> Decrement(string key, ulong defaultValue, ulong delta, ulong cas)
{
throw new NotImplementedException();
return new CasResult<ulong>();
}

public ulong Decrement(string key, ulong defaultValue, ulong delta, DateTime expiresAt)
{
throw new NotImplementedException();
return default(ulong);
}

public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas)
{
throw new NotImplementedException();
return new CasResult<ulong>();
}

public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, DateTime expiresAt, ulong cas)
{
throw new NotImplementedException();
return new CasResult<ulong>();
}

public void Dispose()
Expand Down Expand Up @@ -118,72 +119,72 @@ public async Task<T> GetValueAsync<T>(string key)

public IDictionary<string, CasResult<object>> GetWithCas(IEnumerable<string> keys)
{
throw new NotImplementedException();
return new Dictionary<string, CasResult<object>>();
}

public CasResult<object> GetWithCas(string key)
{
throw new NotImplementedException();
return new CasResult<object>();
}

public CasResult<T> GetWithCas<T>(string key)
{
throw new NotImplementedException();
return new CasResult<T>();
}

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<ulong> Increment(string key, ulong defaultValue, ulong delta, ulong cas)
{
throw new NotImplementedException();
return new CasResult<ulong>();
}

public ulong Increment(string key, ulong defaultValue, ulong delta, DateTime expiresAt)
{
throw new NotImplementedException();
return default(ulong);
}

public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas)
{
throw new NotImplementedException();
return new CasResult<ulong>();
}

public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, DateTime expiresAt, ulong cas)
{
throw new NotImplementedException();
return new CasResult<ulong>();
}

public bool Prepend(string key, ArraySegment<byte> data)
{
throw new NotImplementedException();
return false;
}

public CasResult<bool> Prepend(string key, ulong cas, ArraySegment<byte> data)
{
throw new NotImplementedException();
return new CasResult<bool>();
}

public bool Remove(string key)
{
return true;
}

public async Task<bool> RemoveAsync(string key)
public Task<bool> RemoveAsync(string key)
{
return true;
return Task.FromResult<bool>(false);
}

public ServerStats Stats()
{
throw new NotImplementedException();
return new ServerStats(new Dictionary<EndPoint, Dictionary<string, string>>());
}

public ServerStats Stats(string type)
Expand Down Expand Up @@ -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<object> value)
{
throw new NotImplementedException();
value = new CasResult<object>();
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;
}
}
}