Use Case for Ephemerons?

Here’s another use (disclaimer: this is my project).

What’s happening here is that I’m using an ‘ephemeral cache’ (i.e. a cache backed by an ephemeron hash table, here) to store subscribers to a ‘topic’, i.e. a pub-sub bus. You get a subscription token when you subscribe to a topic, and part of that token is the cache key. The cache is ‘ephemeral’ so as soon as the subscription token goes out of scope, it and its corresponding subscription (concretely, the stream and its push function) are automatically deleted from the cache.

Hence, there’s no ‘unsubscribe’ or ‘close topic’ functionality–it’s assumed that you want to unsubscribe if you let the subscription token go out of scope.

3 Likes