Package screenlets :: Module backend :: Class CachingBackend
[hide private]
[frames] | no frames]

Class CachingBackend

source code

ScreenletsBackend --+
                    |
                   CachingBackend

A backend that stores the settings in arrays and saves after a short interval to avoid overhead when multiple values are set within a short time. The data gets saved into $HOME/.config/Screenlets/<Screenletname>/, in a file for each element (named like its id with the extension '.ini').

Instance Methods [hide private]
 
__init__(self, path) source code
 
delete_instance(self, id)
Delete an instance from the list and from the filesystem.
source code
 
flush(self)
Immediately save all pending data.
source code
 
save_option(self, id, name, value)
Save option for an instance to cache and start saving-timeout for that element (value must be of type string).
source code
 
load_option(self, id, name)
TODO: Load option from the backend (returned as str).
source code
 
load_instance(self, id)
Load all options for the instance with the given id.
source code
 
__load_cache(self)
Load all cached files from path.
source code
 
__save_cache(self)
Save the cache (for all pending instances in queue) to self.path.
source code
Class Variables [hide private]
  __instances = {}
  __delay_time = 3000
  __timeout = None
  __queue = []
  path = ''
Method Details [hide private]

__init__(self, path)
(Constructor)

source code 
Overrides: ScreenletsBackend.__init__

delete_instance(self, id)

source code 
Delete an instance from the list and from the filesystem.
Overrides: ScreenletsBackend.delete_instance

flush(self)

source code 
Immediately save all pending data.
Overrides: ScreenletsBackend.flush

save_option(self, id, name, value)

source code 
Save option for an instance to cache and start saving-timeout for that element (value must be of type string).
Overrides: ScreenletsBackend.save_option

load_option(self, id, name)

source code 
TODO: Load option from the backend (returned as str).
Overrides: ScreenletsBackend.load_option

load_instance(self, id)

source code 
Load all options for the instance with the given id.
Overrides: ScreenletsBackend.load_instance