I find it very easy to count number of active connections using
redis_sip = redis.Redis(host="localhost", port=6379, db=0)
redis_sip.setbit(skey, 1, 1)
redis_sip.setbit(skey, 2, 1)
redis_sip.setbit(skey, 3, 0)
redis_sip.setbit(skey, 4, 1)
print(redis_sip.bitcount(skey)) # shows me 3 connections
But for this to work I need to be able to set a TTL for each individual bit.
i.e. when a remote agent makes a connection, I can set the bit to 1. If bitwise expiry is supported, then the bit will be flipped after a length of inactivity.
Is it doable at all in Redis? If not, what is an alterantive?