class Presence
TTL = 60
def initialize(redis: Redis.current)
@redis = redis
end
def touch(room_id, member_id)
key = "presence:room:#{room_id}"
@redis.sadd(key, member_id)
@redis.expire(key, TTL)
end
def members(room_id)
@redis.smembers("presence:room:#{room_id}").map(&:to_i)
end
end
Presence is often more about “who is here now” than perfect accuracy. Use Redis sets with expiries updated by pings. This keeps the system simple and operationally understandable.