Azure Redis Cache connected list

111 Views Asked by At

I am trying to understand what is "client list" command from redis showing me. I was of the opinion that it shows me number of clients connected to redis irrespective of commands issued from the connected clients. For e.g: If I have a webapp connected to local redis server I am hoping to see one entry for the web app when I issue "client list"

But what I saw was below: Initial connect and firing redis SetAsync (I see 2 entries different ports in addr):

id=4 addr=[::1]:56674 laddr=[::1]:6379 fd=9 name= age=16 idle=4 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 multi-mem=0 rbs=1280 rbp=0 obl=0 oll=0 omem=0 tot-mem=2184 events=r cmd=set user=default redir=-1 resp=2 lib-name=SE.Redis lib-ver=2.6.122.38350

id=5 addr=[::1]:56676 laddr=[::1]:6379 fd=10 name= age=16 idle=16 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=1984 events=r cmd=subscribe user=default redir=-1 resp=2 lib-name=SE.Redis lib-ver=2.6.122.38350

When issuing GetAsync (I see 2 entries different ports in addr):

id=4 addr=[::1]:56674 laddr=[::1]:6379 fd=9 name= age=359 idle=4 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 multi-mem=0 rbs=1280 rbp=0 obl=0 oll=0 omem=0 tot-mem=2184 events=r cmd=get user=default redir=-1 resp=2 lib-name=SE.Redis lib-ver=2.6.122.38350

id=5 addr=[::1]:56676 laddr=[::1]:6379 fd=10 name= age=359 idle=6 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=0 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=1984 events=r cmd=ping user=default redir=-1 resp=2 lib-name=SE.Redis lib-ver=2.6.122.38350

Why are there extra entries? Does each set or get or keyexists request open a new connection?

1

There are 1 best solutions below

0
Sampath On
  • In the case of the StackExchange.Redis library, each IDatabase instance represents a pool of connections to a Redis server. Within this pool, connections can be reused for multiple operations, and the library manages the connections for you. So, multiple SET, GET, or KeyExists requests will typically reuse connections from the connection pool rather than opening a completely new connection for each request. enter image description here
  • StackExchange.Redis uses a connection pool to manage connections to the Redis server, and multiple commands like SET, GET, or KeyExists can reuse connections from this pool rather than opening a new connection for each request.
  • the CLIENT LIST command provides information about client connections to the Redis server. Each line in the output represents a single client connection.
  • The multiple entries for different connections, and each entry provides information about that specific connection.

Sample code using set and get:

using StackExchange.Redis;
using System;
class Program
{
    static void Main(string[] args)
    {
        // Connection string for your Azure Redis Cache instance
        string connectionString = "geetharedis.redis.cache.wi";
        ConnectionMultiplexer connection = ConnectionMultiplexer.Connect(connectionString);
        IDatabase database = connection.GetDatabase();
        database.StringSet("myKey", "Hello, Redis!");
         string value = database.StringGet("myKey");
         Console.WriteLine($"Value retrieved from Redis: {value}");
         connection.Close();
    }
}

enter image description here

enter image description here