Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Get<T> (and others) Operation #73

Open
fernandozago opened this issue Apr 1, 2022 · 0 comments
Open

Async Get<T> (and others) Operation #73

fernandozago opened this issue Apr 1, 2022 · 0 comments

Comments

@fernandozago
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant