Sentix v1.0.3 Sentix.Cache
This module just provides a cache interface which can back multiple Sentix watchers, to make sure that we have some form of persistence (rather than relying on the developer to remember to reconnect on crashes).
Currently the only provided functions are based around subscriber storage (in order to persist across crashes), and paths of binaries to avoid having to look for them on every execution.
Summary
Functions
Adds a subscriber against the provided Sentix name
Locates a binary on the host system, if possible
Retrieves the list of subscribers for a provided Sentix name
Sets the subscribers for a given Sentix watcher
Functions
add_subscriber(name :: atom, subs :: [pid], sub :: pid) :: subs :: [pid]
Adds a subscriber against the provided Sentix name.
This is a convenience method to avoid having to check whether the list includes the provided subscriber every time we wish to add a subscriber (because we don’t want to duplicate messages to the subscriber).
Locates a binary on the host system, if possible.
Once the binary has been located, it’s stored inside the cache to speed up future
lookups. We use :os.find_executable/1
under the hood to locate the binary.
Retrieves the list of subscribers for a provided Sentix name.
This simply hits the backing cache for the provided name, and returns an empty list if the name does not exist inside the cache.