comparison src/core/constants.py @ 2109:85f3e12e984d

core (memory/cache): file caching handling, first draft: instead of having file caching handled individually by plugins, a generic module has been added in memory. - Cache can be global or associated to a profile. In the later case, client.cache can be used. - Cache are managed with unique ids (which can be any unique unicode, hash uuid, or something else). - To know if a file is in cache, getFilePath is used: if the file is in cache, its absolute path is returned, else None is returned. - To cache a file, cacheData is used with at list the source of cache (most of time plugin import name), and unique id. The method return file opened in binary writing mode (so cacheData can - and should - be used with "with" statement). - 2 files will be created: a metadata file (named after the unique id), and the actual file. - each file has a end of life time, after it, the cache is invalidated and the file must be requested again.
author Goffi <goffi@goffi.org>
date Thu, 05 Jan 2017 20:23:38 +0100
parents c96fe007ca41
children c42aab22c2c0
comparison
equal deleted inserted replaced
2108:70f23bc7859b 2109:85f3e12e984d
129 NS_XML = 'http://www.w3.org/XML/1998/namespace' 129 NS_XML = 'http://www.w3.org/XML/1998/namespace'
130 NS_CLIENT = 'jabber:client' 130 NS_CLIENT = 'jabber:client'
131 NS_FORWARD = 'urn:xmpp:forward:0' 131 NS_FORWARD = 'urn:xmpp:forward:0'
132 NS_DELAY = 'urn:xmpp:delay' 132 NS_DELAY = 'urn:xmpp:delay'
133 NS_XHTML = 'http://www.w3.org/1999/xhtml' 133 NS_XHTML = 'http://www.w3.org/1999/xhtml'
134
135 ## Directories ##
136 CACHE_DIR = u'cache'
134 137
135 138
136 ## Configuration ## 139 ## Configuration ##
137 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend) 140 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend)
138 if "org.goffi.cagou.cagou" in BaseDirectory.__file__: 141 if "org.goffi.cagou.cagou" in BaseDirectory.__file__:
279 SAVEFILE_DATABASE = APP_NAME_FILE + ".db" 282 SAVEFILE_DATABASE = APP_NAME_FILE + ".db"
280 IQ_SET = '/iq[@type="set"]' 283 IQ_SET = '/iq[@type="set"]'
281 ENV_PREFIX = 'SAT_' # Prefix used for environment variables 284 ENV_PREFIX = 'SAT_' # Prefix used for environment variables
282 IGNORE = 'ignore' 285 IGNORE = 'ignore'
283 NO_LIMIT = -1 # used in bridge when a integer value is expected 286 NO_LIMIT = -1 # used in bridge when a integer value is expected
287 DEFAULT_MAX_AGE = 1209600 # default max age of cached files, in seconds
284 288
285 289
286 ## ANSI escape sequences ## 290 ## ANSI escape sequences ##
287 # XXX: used for logging 291 # XXX: used for logging
288 # XXX: they will be probably moved in a dedicated module in the future 292 # XXX: they will be probably moved in a dedicated module in the future