stackexchange.redis

Redis Stack Exchange how to delete or get keys by pattern

送分小仙女□ 提交于 2019-11-28 07:30:46
问题 I installed Stack Exchange redis client in C#. I can only delete one key or array of keys but I don't know how to delete keys with prefix. Or another solution can be first get all keys by pattern and then delete them. But I don't know how to get keys by pattern too. 回答1: Deletion is separate by key, unless you are flushing the entire database. Key scanning is readily available on the IServer API, and is discussed much more here: https://stackexchange.github.io/StackExchange.Redis/KeysScan

Pipelining vs Batching in Stackexchange.Redis

拟墨画扇 提交于 2019-11-28 04:44:59
I am trying to insert a large(-ish) number of elements in the shortest time possible and I tried these two alternatives: 1) Pipelining: List<Task> addTasks = new List<Task>(); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; Task<bool> addAsync = redisDB.SetAddAsync(string.Format(keyFormat, row.Field<int>("Id")), row.Field<int>("Value")); addTasks.Add(addAsync); } Task[] tasks = addTasks.ToArray(); Task.WaitAll(tasks); 2) Batching: List<Task> addTasks = new List<Task>(); IBatch batch = redisDB.CreateBatch(); for (int i = 0; i < table.Rows.Count; i++) { DataRow row =

How to define connection string for session state in Azure

旧巷老猫 提交于 2019-11-28 04:44:05
问题 I am using the RedisSessionStateProvider using a procedimient like this https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-session-state-caching/ I define its connection string in web.config , in this example is XXXXXX . <system.web> <compilation debug="true" targetFramework="4.6.1" /> <httpRuntime targetFramework="4.5" /> <globalization culture="es-CO" uiCulture="es" /> <customErrors mode="Off" /> <sessionState mode="Custom" customProvider="SessionStateStore">

How does StackExchange.Redis use multiple endpoints and connections?

自作多情 提交于 2019-11-28 02:38:05
问题 As explained in the StackExchange.Redis Basics documentation, you can connect to multiple Redis servers, and StackExchange.Redis will automatically determine the master/slave setup. Quoting the relevant part: A more complicated scenario might involve a master/slave setup; for this usage, simply specify all the desired nodes that make up that logical redis tier (it will automatically identify the master): ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("server1:6379,server2:6379");

Timeout exception after async commands and Task.WhenAny awaits in StackExchange.Redis

这一生的挚爱 提交于 2019-11-27 21:48:42
问题 I'm experiencing the so-called Timeout performing HGET company:product:settings, inst: 1, queue: 8, qu=0, qs=8, qc=0, wr=0/0, in=79/1 timeout exception. It's strange because the same Redis instance and in the same machine is storing data, but it's a specific application which throws this exception. Update: In fact, the same application, one line above receives data from Redis. The issue is with HGET . Also, I've increased timeouts on multiplexer configuration to 6 seconds with no luck. In

StackExchange.Redis - LockTake / LockRelease Usage

烈酒焚心 提交于 2019-11-27 18:23:24
I am using Redis with StackExchange.Redis. I have multiple threads that will at some point access and edit the value of the same key, so I need to synchronize the manipulation of the data. Looking at the available functions, I see that there are two functions, TakeLock and ReleaseLock. However, these functions take both a key and a value parameter rather than the expected single key to be locked. The intellisene documentation and source on GitHub don't explain how to use the LockTake and LockRelease functions or what to pass in for the key and value parameters. Q: What is the correct usage of

How does ConnectionMultiplexer deal with disconnects?

試著忘記壹切 提交于 2019-11-27 15:57:00
问题 The Basic Usage documentation for StackExchange.Redis explains that the ConnectionMultiplexer is long-lived and is expected to be reused. But what about when the connection to the server is broken? Does ConnectionMultiplexer automatically reconnect, or is it necessary to write code as in this answer (quoting that answer): if (RedisConnection == null || !RedisConnection.IsConnected) { RedisConnection = ConnectionMultiplexer.Connect(...); } RedisCacheDb = RedisConnection.GetDatabase(); Is the

Pipelining vs Batching in Stackexchange.Redis

[亡魂溺海] 提交于 2019-11-27 00:30:21
问题 I am trying to insert a large(-ish) number of elements in the shortest time possible and I tried these two alternatives: 1) Pipelining: List<Task> addTasks = new List<Task>(); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; Task<bool> addAsync = redisDB.SetAddAsync(string.Format(keyFormat, row.Field<int>("Id")), row.Field<int>("Value")); addTasks.Add(addAsync); } Task[] tasks = addTasks.ToArray(); Task.WaitAll(tasks); 2) Batching: List<Task> addTasks = new List<Task>

StackExchange.Redis - LockTake / LockRelease Usage

≯℡__Kan透↙ 提交于 2019-11-26 19:15:20
问题 I am using Redis with StackExchange.Redis. I have multiple threads that will at some point access and edit the value of the same key, so I need to synchronize the manipulation of the data. Looking at the available functions, I see that there are two functions, TakeLock and ReleaseLock. However, these functions take both a key and a value parameter rather than the expected single key to be locked. The intellisene documentation and source on GitHub don't explain how to use the LockTake and