modglobal v0.2.4 Modglobal View Source
Modglobal provides a simple key-value store that is unique per module. It is useful when you would otherwise need a GenServer to hold onto some state
Setup
For each module you need globals, add use Modglobal
.
Usage
YourModule.set_global(key, value)
YourModule.get_global(key), etc.
If you would rather not use the *_global convenience functions, the regular API is also supported as follows:
Modglobal.get(__MODULE__, key)
Modglobal.set(__MODULE__, key, value)
, etc…
Link to this section Summary
Functions
Deletes a given key from the module, and returns the value deleted. If the key was not present, then nil is returned
See get/3, where the default value is populated to be nil
For a module, retrieves the value of the passed in key. If the key is not present, then the default value is returned
Returns true if the key is present in the global cache, false otherwise. Note that this just checks the presence of the keys, even falsey values will return true
Increments an integer by 1 atomically, and returns the previous value. The initial value is 0, if the key is not already set
Sets the value, overwriting if necessary, to the key for the given module
Link to this section Functions
Deletes a given key from the module, and returns the value deleted. If the key was not present, then nil is returned.
See get/3, where the default value is populated to be nil
For a module, retrieves the value of the passed in key. If the key is not present, then the default value is returned
Returns true if the key is present in the global cache, false otherwise. Note that this just checks the presence of the keys, even falsey values will return true
Increments an integer by 1 atomically, and returns the previous value. The initial value is 0, if the key is not already set
Sets the value, overwriting if necessary, to the key for the given module.