moscajs / aedes-persistence-redis

Aedes persistence, backed by redis
MIT License
21 stars 23 forks source link

[question]Session expiration implementation #101

Open friesendrywall opened 2 years ago

friesendrywall commented 2 years ago

MQTT 5 allows session expiration, so at some point if someone decides to move ahead with implementation, the persistence modules will need some work done. At present I'm considering incorporating it into a MQTT 5 server I've been working on.

What would the roadmap be for this to happen, would the work have to start with aedes-cached-persistence, or would it have start with the individual persistences?

As an alternate, I suppose a person could do a plugin similar to the way the aedes-stats plugin works, but that may be problematic if the internals of the persistences change.

The way I'd see it, it could be separate api calls, or integrated, but essentially I'd be thinking something like:

sessionStart(clientId)
sessionRefresh(clientId) // Reset the session expiration
expiredSessions() // the broker would clear expired sessions based on returned items (client and client:* keys)

For redis I'm thinking about using a sorted set with value = clientId, score = expiration.

robertsLando commented 2 years ago

This needs to be implemented on aedes-persistence first and then aedes-cached-persistence and at last on all other persistences. The plugin way isn't good IMO