dotnet / dotnet/aspnetcore

Performance Improvements for Redis cache

Open
#32,857 3 comments 0 reactions 0 assignees View on GitHub
area-middleware feature-caching
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is your feature request related to a problem? Please describe.

I have begun using the Redis distributed cache implementation. I'm wondering if there are some simple things that could be done to improve its performance.

### Describe the solution you'd like

A couple of ideas spring to mind:

1. Use the [FireAndForget](https://stackexchange.github.io/StackExchange.Redis/Basics.html#sync-vs-async-vs-fire-and-forget) option when performing write operations - since a cache doesn't often have the same consistency requirements as a typical datastore, it seems like setting EXPIRE/PEXPIRE, or even writing values, could use the `FireAndForget` command flag, and return sooner to the caller.
2. Encapsulate read and write options in Lua scripts - rather than the above, encapsulate all the Redis commands that need to take place to cache an item (or get it and refresh the timeout) within Lua scripts. There's a nice example I came across in this [NHibernate cache](https://github.com/TheCloudlessSky/NHibernate.Caches.Redis/blob/master/src/NHibernate.Caches.Redis/RedisCache.cs#L34-L41) that could serve as inspiration.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.