moobius.database.database_interface#
Module-level functions#
(No module-level functions)
Class DatabaseInterface#
An abstract base class that is to be inherited by different database backends. Currently available as of July 2024: JSONDatabase, NullDatabase, and RedisDatabase.
When a MoobiusStorage object is constructed: >>> MoobiusStorage(self.client_id, channel_id, db_config=self.db_config) An internal DatabaseInterface is constructed.
Each demo’s on_start() function passes calls MoobiusStorage(self.client_id, channel_id, db_config=self.db_config) The db_config can be a dict or a .json file name. An example: >>> [{“implementation”: “json”, “name”: “health_bars”, “load”: true, “clear”: false, >>> “settings”: {“root_dir”: “json_db”}} >>> {“implementation”: “redis”, “name”: “mana_bars”, “load”: true, “clear”: false, >>> “settings”: {“root_dir”: “json_db”}}]
The Moobius (service) class, on initialization, create one MoobiusStorage object per channel, unless initalize_channel() is overridden. Each MoobiusStorage object creates one CachedDict per element in the db-config list, using the “name” to dynamically generate an attribute. The “implementation” sets the engine to be used by CachedDict.
DatabaseInterface.get_value#
**DatabaseInterface.get_value**(self, key)
__key:__ Key.
The tuple of (is_success, value).
(this function does not raise any notable errors)
DatabaseInterface.set_value#
**DatabaseInterface.set_value**(self, key, value)
__key:__ Key.
__value:__ Value.
The tuple of (is_success=True, key) or (is_success=False, err_message).
(this function does not raise any notable errors)
DatabaseInterface.delete_key#
**DatabaseInterface.delete_key**(self, key)
__key:__ Key.
The tuple of (is_success=True, key) or (is_success=False, err_message).
(this function does not raise any notable errors)
DatabaseInterface.all_keys#
**DatabaseInterface.all_keys**(self)
__(this class constructor accepts no arguments):__
The iterable of all keys, the details of which depend on the implementation.
(this function does not raise any notable errors)
Class attributes#
DatabaseInterface.ABC