DEV Community

Strongly-Typed Redis Caching in ASP.NET Core (Without the Boilerplate) (opens in new tab)

Discussed on DEV

If you've added Redis to an ASP.NET Core app, you've probably met IDistributedCache. It does the job, but it only speaks in byte[] and string keys. So every read or write turns into the same little ritual: serialize, null-check, deserialize. Do that in one place and it's fine. Do it in twenty, and you've got a pile of nearly identical caching code that's surprisingly easy to get wrong. This post keeps Redis as your store but caches typed objects instead of byte arrays, using a small open-sour...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help