Questions tagged [stackexchange.redis]

A high performance .NET redis client library

StackExchange.Redis is a high-performance redis client library for .NET and Mono applications, allowing massively concurrent usage from multiple threads (for example, on a busy web site). The library exposes synchronous, asynchronous and fire-and-forget APIs, allowing it to support a wide variety of use-cases. Additionally, the client supports internal management of connections to multiple servers, including both master/slave setups and redis "cluster". The entire set of redis functionality is included (including auto-resubscribe for pub/sub connections), with the exception of the blocking pop operations, which are not compatible with the multiplexer design.

The client was designed, created and released by the Stack Exchange development team, and is the redis client that drives the Stack Exchange Network (including Stack Overflow). It supersedes the BookSleeve client that Stack Exchange had been using previously

Links:

1108 questions
15
votes
1 answer

How to store a byte array to StackExchange.Redis?

I want to use the MessagePack, ZeroFormatter or protobuf-net to serialize/deserialize a generic list and store it in Redis using the stackexchange.redis client. Now I'm storing a JSON string with the StringSetAsync() method. But I can't find any…
tedi
  • 6,350
  • 5
  • 52
  • 67
15
votes
1 answer

Should `StackExchange.Redis.ConnectionMultiplexer` be `AddSingleton` or `AddScope` in .NET Core dependency injection?

I'm adding a Redis connection to .NET Core using StackExchange.Redis, it currently looks something like this: public static IServiceCollection AddRedisMultiplexer( this IServiceCollection services, Func getOptions =…
Keith
  • 150,284
  • 78
  • 298
  • 434
15
votes
4 answers

How to add Generic List to Redis via StackExchange.Redis?

For example, if I have a model called Customer public class Customer { public string FirstName { get; set; } public string LastName { get; set; } public string Address1 { get; set; } public string City { get; set;…
Shane
  • 4,185
  • 8
  • 47
  • 64
14
votes
2 answers

Can I use StackExchange.Redis to store a Null value in Redis?

Is there any way to use the StackExchange.Redis client to store a Null value in Redis? If you use IDatabase.StringGet(key) then the returning of Null is used to signify that there "was no result". Therefore if you use IDatabase.StringSet(key, null)…
oatsoda
  • 2,088
  • 2
  • 26
  • 49
14
votes
1 answer

Connecting to a remote Azure Redis Cache using Redis CLI

I'm trying to use redis-cli to connect to my Redis cache hosted in MS Azure. I created a shortcut to the executable in Windows, passing through the hostname port and pw: "C:\Program Files\Redis\redis-cli.exe" -h myredis.redis.cache.windows.net -p…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
14
votes
1 answer

StackExchange.Redis key expiration by UTC date

I am working with StackExchange.Redis and building a Redis client interface RedisClientManager. In my interface I have 2 key setters (by timespan expiration and datetime expiration): By timespan: public void Set(string key, object value, TimeSpan…
freethinker
  • 2,257
  • 4
  • 26
  • 49
14
votes
1 answer

Is there a way to convert RedisValue[] to string[]?

I have an array RedisValue[] returned from the StackExchange.Redis client. I want to take each of the values (which are actually JSON strings) in the array and join them together to get a valid JSON string that I can return to the client. Here's…
Jay Stevens
  • 5,863
  • 9
  • 44
  • 67
13
votes
1 answer

How should StackExchange.Redis IDatabase object be used in a multi-threaded application?

I'm getting mixed messages from the StackExchange.Redis documentation about how to use an IDatabase. In the Basic Usage doc it says: The object returned from GetDatabase is a cheap pass-thru object, and does not need to be stored. This give the…
Sean
  • 8,407
  • 3
  • 31
  • 33
13
votes
2 answers

Redis distributed increment with locking

I have a requirement for generating an counter which will be send to some api calls. My application is running on multiple node so some how I wanted to generate unique counter. I have tried following code public static long…
Kamran Shahid
  • 3,954
  • 5
  • 48
  • 93
13
votes
1 answer

Storing Lua scripts with stackexchange.redis

I'm trying to use StackExchange.Redis on Azure WebApp and need to run some Lua scripts. The recommended way is to load the scripts to the server but I have difficulty understanding the correct pattern. The way I think it should be done is on WebApp…
ziv
  • 3,641
  • 3
  • 21
  • 26
13
votes
2 answers

Azure Redis Cache - pool of ConnectionMultiplexer objects

We are using C1 Azure Redis Cache in our application. Recently we are experiencing lots of time-outs on GET operations. According to this article, one of possible solutions is to implement pool of ConnectionMultiplexer objects. Another possible…
Jakub Holovsky
  • 6,543
  • 10
  • 54
  • 98
13
votes
1 answer

Does Stackexchange.Redis' fire and forget guarantees delivery?

I understand that CommandFlags.FireAndForget is intended for situations that you don't care about the response. Does it also guarantee delivery even though the response isn't important for the running application?
DTown
  • 2,132
  • 2
  • 20
  • 29
13
votes
1 answer

The correct way of using StackExchange.Redis

The idea is to use less connection and better performance. Does the connection expire at any time? And for another question, does _redis.GetDatabase() open new connection? private static ConnectionMultiplexer _redis; private static IDatabase…
Babak
  • 3,716
  • 6
  • 39
  • 56
13
votes
1 answer

How to flushdb using StackExchange.Redis?

Is there a way to delete all keys in redis using stackexchange.redis? I am trying to flush my redis database in my unit test setup. Thanks.
Misterhex
  • 929
  • 1
  • 11
  • 19
12
votes
2 answers

Azure Function App Could not load System.IO.Pipelines connecting to Redis

Created a new Function App, HTTP trigger in VS2019 (16.8.3) to connect to Azure Cache for Redis. Added StackExchange.Redis 2.2.4 from nuget. local.settings.json contains the key/value of RedisConnectionFromKeyVault and the Primary Connection String…
briask
  • 413
  • 4
  • 15
1 2
3
73 74