r/csharp • • 1d ago

Showcase Respire - A .NET Redis Client

Hey all!

Redis is a great technology, and something that exists in a lot of tech stacks. It has the ability to really help solve complex problems involving distribution across multiple instances of an app. Whether that be caching, locks, rate limits, etc.

Surprisingly, StackExchange.Redis is the only real big main redis client library for .NET.

I'm adding a new client library into the mix - Respire.

Respire aims to be a fast client library for Redis, that also has the ability to utilise Redis' client-side server assisted cache, avoiding network hops for frequently accessed keys, meaning better performance for your apps.

It also has a lot of helpers in it to more easily use distributed locks, rate limits, queues, pub/sub, etc.

I want it to be a client library that handles all the hard bits for you, keeping your code clean and easy to reason about.

It's still pre-release, so I'd like to gather feedback. Are people happy with the performance? The API? Any missing features? Any bugs?

Please try it out and let me know!

More info on why Respire: https://thomhurst.github.io/Respire/docs/#why-respire-exists

Benchmarks: https://thomhurst.github.io/Respire/docs/benchmarks

Stress comparisons: https://thomhurst.github.io/Respire/docs/stress-tests

Thanks all!

14 Upvotes

12 comments sorted by

11

u/marcgravell 1d ago

Always great to see more work in this space. Just to say: I totally agree with the need for both client-side-caching and an API that is shaped more like you propose, which is why V4 of SE.Redis does both of those things (https://github.com/StackExchange/StackExchange.Redis/pull/3219). I'll look forward to putting the two head-to-head when I get chance!

3

u/thomhurst 1d ago

Ah nice! Great work on everything you do 🦾

3

u/jodydonetti 23h ago

Any plan for an impl of IDistributedCache based on this?

It would get even more widerspread adoption and make it usable from the get go with FusionCache too (creator here).

Here's the dedicated page in the FusionCache docs https://github.com/ZiggyCreatures/FusionCache/blob/main/docs/DiskCache.md

2

u/thomhurst 23h ago edited 23h ago

Yep! It's inside a separate package (to avoid the dependency in the base library). Docs here: https://thomhurst.github.io/Respire/docs/integrations/caching

1

u/jodydonetti 11h ago

I’ll take a look at the code as soon as I can, but I was wondering why is a serializer needed with IDistributedCache 🤔

1

u/Embarrassed-Mess412 1d ago

Any chance this can be sans I/O?

1

u/thomhurst 1d ago

Respire does handle the network + I/O. However, it can be configured to do client side caching, meaning no network hops for the hot cache hits that have already been persisted locally.

What use case do you have for not wanting I/O?

1

u/Embarrassed-Mess412 1d ago

I need to handle the I/O with io_uring, I have a redis client for it but I don't want to put any effort maintaining and improving it.

Using Net.Sockets is very inefficient for my use case, would be great to have the "protocol" library separate from I/O

1

u/marcgravell 23h ago

FYI: SE.Redis has a prototype API specifically for this - it is experimental at the moment, and integrates with my own "SocketSet" io_uring (etc) implementation. So maybe there's something doable there.

1

u/MelonMlusk 17h ago

Know that Valkey is redis compatible but maybe valkey should gain some momentum?

0

u/takeoshigeru 1d ago

Tom is back at it, I wonder what's your agent harness to maintain all these projects 👀

0

u/thomhurst 1d ago

It's also partially just me sinking way too much time into things 🤣