-
Notifications
You must be signed in to change notification settings - Fork 128
Description
Hello guys.
I'm doing some research on distributed memory caching using NCache. Its really a great product. Thank you for that.
But i'm experiencing some dificulties about getting data out of the cache to my application. Especifically async calls.
Thats what I got.
(My Application) <-> (NCache Cluster (3 nodes)) <-> (SqlServer)
I'm choosing the option of Read-Thru and looking up to the database for the keys that is not existing on the cache.
It is a remote database that sits on the cloud, and its taking about ~5ms to bring down the data from the sqlserver to the cache and then the app (~5ms across all that).
After that (db lookup) its doing really fast because i'm using the Client Cache (In-Proc isolation) to speed things up...
My concern is that, Get<T> isn't async. so it locks my application for (5ms).
Any takes on that ?
Update:
I fixed that issue adding this extension for the Get<T> calls, but it's almost certainly not a good code because i'm not taking advantage of a "in-memory" calls when using a cache isolation in-proc when the data already on the cache.
Taking advantage of the ValueTask<T> for the GetAsync<T> operation should perform better.
public static class ICacheExtensions
{
public static Task<T> GetAsync<T>(this ICache cache, string key)
{
return Task.Run(() => cache.Get<T>(key));
}
}Thank you.