stackexchange.redis

The correct way of using StackExchange.Redis

余生长醉 提交于 2019-12-05 05:03:06
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 _db; public RedisCacheProvider(string configuration) { if (_redis == null) lock (myLock) if (_redis == null) { _redis = ConnectionMultiplexer.Connect(configuration); _db = _redis.GetDatabase(); } } public async Task<string> GetString(string key) { string result = null; RedisValue val = await _db.StringGetAsync(key); if (val.HasValue) result = val; return

Azure Redis StackExchange.Redis ConnectionMultiplexer in ASP.net MVC

落花浮王杯 提交于 2019-12-05 04:51:30
I have read that in order to connect to Azure Redis cache is best to follow this practice: private static ConnectionMultiplexer Connection { get { return LazyConnection.Value; } } private static readonly Lazy<ConnectionMultiplexer> LazyConnection = new Lazy<ConnectionMultiplexer>( () => { return ConnectionMultiplexer.Connect(connStinrg); }); And according to Azure Redis docs: The connection to the Azure Redis Cache is managed by the ConnectionMultiplexer class. This class is designed to be shared and reused throughout your client application, and does not need to be created on a per operation

Timeout performing SET {Key}, inst: 0, mgr: Inactive, queue: 2, qu=1, qs=1, qc=0, wr=1/1, in=0/0

孤人 提交于 2019-12-05 03:25:21
问题 I am trying to save a 90 KB pdf file into Azure Redis Cache using StackExchange.Redis client. I have converted that file into byte array and tried to save it using stringSet method and received error. Code: byte[] bytes = File.ReadAllBytes("ABC.pdf"); cache.StringSet(info.Name, bytes); --> This Line throws exception "Timeout performing SET {Key}, inst: 0, mgr: Inactive, queue: 2, qu=1, qs=1, qc=0, wr=1/1, in=0/0". Kindly Help. 回答1: Timeout performing SET {Key}, inst: 0, mgr: Inactive, queue:

How to determine Redis memory leak?

落爺英雄遲暮 提交于 2019-12-04 23:09:47
问题 Our redis servers are, since yesterday, gradually (200MB/hour) using more memory, while the amount of keys (330K) and their data (132MB redis-rdb-tools) stay about the same. Output of redis-cli info shows 6.89G used memory?! redis_version:2.4.10 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.6 process_id:3437 uptime_in_seconds:296453 uptime_in_days:3 lru_clock:1905188 used_cpu_sys:8605.03 used_cpu_user:1480.46 used_cpu_sys_children:1035.93 used

Running multiple instance of Redis on Centos

拈花ヽ惹草 提交于 2019-12-04 22:00:57
问题 I want to run multiple instance of Redis on Centos 7. Can anyone point me to proper link or post steps here. I googled for the information but I didn't find any relevant information. 回答1: You can run multiple instances of Redis using different ports on a single machine. If this what concerns you then you can follow the below steps. By installing the first Redis instance, it listens on localhost:6379 by default. For Second Instance create a new working directory The default Redis instance uses

Batch set data from Dictionary into Redis

Deadly 提交于 2019-12-04 15:30:17
I am using StackExchange Redis DB to insert a dictionary of Key value pairs using Batch as below: private static StackExchange.Redis.IDatabase _database; public void SetAll<T>(Dictionary<string, T> data, int cacheTime) { lock (_database) { TimeSpan expiration = new TimeSpan(0, cacheTime, 0); var list = new List<Task<bool>>(); var batch = _database.CreateBatch(); foreach (var item in data) { string serializedObject = JsonConvert.SerializeObject(item.Value, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new SerializeAllContractResolver(), ReferenceLoopHandling =

How to read multiple Sets stored on Redis using some command or LUA script

别来无恙 提交于 2019-12-04 14:01:33
I want to get all the sets from Redis using a list of keys in single call. As per the documentation, Redis provides SSCAN command for that but as I am using StackExchange.Redis as a Redis adapter, I guess this command does not have any such method in this adapter. So there two things I am looking for: I looking forward to execute SSCAN using the LUA script but was not able to find any such example over the internet. Can anyone share how to call SSCAN from LUA with multiple SET Keys. Also for the StackExchange.Redis, if I execute multiple SetMembers() in a transaction, is it similar to use

Azure Redis cache - timeouts on GET calls

社会主义新天地 提交于 2019-12-04 12:20:16
We've got several web and worker roles in Azure connecting to our Azure Redis cache via the StackExchange.Redis library, and we're receiving regular timeouts that are making our end-to-end solution grind to a halt. An example of one of them is below: System.TimeoutException: Timeout performing GET stream:459, inst: 4, mgr: Inactive, queue: 12, qu=0, qs=12, qc=0, wr=0/0, in=65536/0 at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor 1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\58bc9a6df18a3782\StackExchange.Redis\StackExchange

What is the difference between StackExchange.Redis and StackExchange.Redis.StrongName?

不羁岁月 提交于 2019-12-04 08:50:19
问题 While I was following Azure documentation for how to use Redis Cache in Azure Portal I noticed this note: If you prefer to use a strong-named version of the StackExchange.Redis client library, choose StackExchange.Redis.StrongName; otherwise choose StackExchange.Redis. What is the strong-named ? and what is the proc and cons ? How to decide if I need it or not in my application ? 回答1: Do you need a strongly named Redis library? In all likelihood, especially if you never even encountered this

Does Stackexchange.Redis' fire and forget guarantees delivery?

半世苍凉 提交于 2019-12-04 03:44:39
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? Actually, the Redis protocol does not really support "fire and forget" operations. Except for pub/sub traffic, all Redis commands are matched with a reply, and there is no way to tell the Redis server to omit the reply. Now some clients (like StackExchange.Redis) simulates a "fire and forget" mode through an asynchronous implementation of the protocol. Actually, the "fire and forget"