Package omeroweb :: Package webgateway :: Module webgateway_cache :: Class WebGatewayCache
[hide private]
[frames] | no frames]

Class WebGatewayCache

source code


Caching class for webgateway.

Instance Methods [hide private]
 
__init__(self, backend=None, basedir=CACHE)
Initialises cache
source code
 
_updateCacheSettings(self, cache, timeout=None, max_entries=None, max_size=None)
Updates the timeout, max_entries and max_size (if specified) for the given cache
source code
 
__del__(self)
Tries to remove the lock on this cache.
source code
boolean
tryLock(self)
simple lock mechanisn to avoid multiple processes on the same cache to step on each other's toes.
source code
 
handleEvent(self, client_base, e)
Handle one event from blitz.onEventLogs.
source code
 
eventListener(self, client_base, events)
handle events coming our way from blitz.onEventLogs.
source code
 
clear(self)
Clears all the caches.
source code
 
_cache_set(self, cache, key, obj)
Calls cache.set(key, obj)
source code
 
_cache_clear(self, cache, key)
Calls cache.delete(key)
source code
 
invalidateObject(self, client_base, user_id, obj)
Invalidates all caches for this particular object
source code
 
_thumbKey(self, r, client_base, user_id, iid, size)
Generates a string key for caching the thumbnail, based on the above parameters
source code
 
setThumb(self, r, client_base, user_id, iid, obj, size=())
Puts thumbnail into cache.
source code
String
getThumb(self, r, client_base, user_id, iid, size=())
Gets thumbnail from cache.
source code
 
clearThumb(self, r, client_base, user_id, iid, size=None)
Clears thumbnail from cache.
source code
 
_imageKey(self, r, client_base, img, z=0, t=0)
Returns a key for caching the Image, based on parameters above, including rendering settings specified in the http request.
source code
 
setImage(self, r, client_base, img, z, t, obj, ctx='')
Puts image data into cache.
source code
String
getImage(self, r, client_base, img, z, t, ctx='')
Gets image data from cache.
source code
 
clearImage(self, r, client_base, user_id, img)
Clears image data from cache using default rendering settings (r=None) T and Z indexes ( = 0).
source code
 
setSplitChannelImage(self, r, client_base, img, z, t, obj)
Calls setImage with '-sc' context
source code
String
getSplitChannelImage(self, r, client_base, img, z, t)
Calls getImage with '-sc' context
source code
 
setOmeTiffImage(self, r, client_base, img, obj)
Calls setImage with '-ometiff' context
source code
String
getOmeTiffImage(self, r, client_base, img)
Calls getImage with '-ometiff' context
source code
String
_jsonKey(self, r, client_base, obj, ctx='')
Creates a cache key for storing json data based on params above.
source code
 
clearJson(self, client_base, obj)
Only handles Dataset obj, calling clearDatasetContents
source code
True
setDatasetContents(self, r, client_base, ds, data)
Adds data to the json cache using 'contents' as context
source code
String or None
getDatasetContents(self, r, client_base, ds)
Gets data from the json cache using 'contents' as context
source code
True
clearDatasetContents(self, r, client_base, ds)
Clears data from the json cache using 'contents' as context
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, backend=None, basedir=CACHE)
(Constructor)

source code 

Initialises cache

Parameters:
  • backend - The cache class to use for caching. E.g. FileCache
  • basedir - The base location for all caches. Sub-dirs created for json/ img/ thumb/
Overrides: object.__init__

_updateCacheSettings(self, cache, timeout=None, max_entries=None, max_size=None)

source code 

Updates the timeout, max_entries and max_size (if specified) for the given cache

Parameters:
  • cache (CacheBase or list of caches) - Cache or caches to update.

tryLock(self)

source code 

simple lock mechanisn to avoid multiple processes on the same cache to step on each other's toes.

Returns: boolean
True if we created a lockfile or already had it. False otherwise.

handleEvent(self, client_base, e)

source code 

Handle one event from blitz.onEventLogs.

Meant to be overridden, this implementation just logs.

Parameters:
  • client_base - TODO: docs!
  • e

eventListener(self, client_base, events)

source code 

handle events coming our way from blitz.onEventLogs.

Because all processes will be listening to the same events, we use a simple file lock mechanism to make sure the first process to get the event will be the one handling things from then on.

Parameters:
  • client_base - TODO: docs!
  • events

invalidateObject(self, client_base, user_id, obj)

source code 

Invalidates all caches for this particular object

Parameters:
  • client_base - The server_id
  • user_id - OMERO user ID to partition caching upon
  • obj - The object wrapper. E.g. omero.gateway.ImageWrapper

_thumbKey(self, r, client_base, user_id, iid, size)

source code 

Generates a string key for caching the thumbnail, based on the above parameters

Parameters:
  • r - not used
  • client_base - server-id, forms stem of the key
  • user_id - OMERO user ID to partition caching upon
  • iid - image ID
  • size - size of the thumbnail - tuple. E.g. (100,)

setThumb(self, r, client_base, user_id, iid, obj, size=())

source code 

Puts thumbnail into cache.

Parameters:
  • r - for cache key - Not used?
  • client_base - server_id for cache key
  • user_id - OMERO user ID to partition caching upon
  • iid - image ID for cache key
  • obj - Data to cache
  • size - Size used for cache key. Tuple

getThumb(self, r, client_base, user_id, iid, size=())

source code 

Gets thumbnail from cache.

Parameters:
  • r - for cache key - Not used?
  • client_base - server_id for cache key
  • user_id - OMERO user ID to partition caching upon
  • iid - image ID for cache key
  • size - Size used for cache key. Tuple
Returns: String
Cached data or None

clearThumb(self, r, client_base, user_id, iid, size=None)

source code 

Clears thumbnail from cache.

Parameters:
  • r - for cache key - Not used?
  • client_base - server_id for cache key
  • user_id - OMERO user ID to partition caching upon
  • iid - image ID for cache key
  • size - Size used for cache key. Tuple
Returns:
True

_imageKey(self, r, client_base, img, z=0, t=0)

source code 

Returns a key for caching the Image, based on parameters above, including rendering settings specified in the http request.

Parameters:
  • r - http request - get rendering params 'c', 'm', 'p'
  • client_base - server_id for cache key
  • img - omero.gateway.ImageWrapper for ID
  • obj - Data to cache
  • size - Size used for cache key. Tuple

setImage(self, r, client_base, img, z, t, obj, ctx='')

source code 

Puts image data into cache.

Parameters:
  • r - http request for cache key
  • client_base - server_id for cache key
  • img - ImageWrapper for cache key
  • z - Z index for cache key
  • t - T index for cache key
  • obj - Data to cache
  • ctx - Additional string for cache key

getImage(self, r, client_base, img, z, t, ctx='')

source code 

Gets image data from cache.

Parameters:
  • r - http request for cache key
  • client_base - server_id for cache key
  • img - ImageWrapper for cache key
  • z - Z index for cache key
  • t - T index for cache key
  • ctx - Additional string for cache key
Returns: String
Image data

clearImage(self, r, client_base, user_id, img)

source code 

Clears image data from cache using default rendering settings (r=None) T and Z indexes ( = 0). TODO: Doesn't clear any data stored WITH r, t, or z specified in cache key? Also clears thumbnail (but not thumbs with size specified) and json data for this image.

Parameters:
  • r - http request for cache key
  • client_base - server_id for cache key
  • user_id - OMERO user ID to partition caching upon
  • img - ImageWrapper for cache key
  • obj - Data to cache
  • rtype - True

_jsonKey(self, r, client_base, obj, ctx='')

source code 

Creates a cache key for storing json data based on params above.

Parameters:
  • r - http request - not used
  • client_base - server_id
  • obj - ObjectWrapper
  • ctx - Additional string for cache key
Returns: String
Cache key

setDatasetContents(self, r, client_base, ds, data)

source code 

Adds data to the json cache using 'contents' as context

Parameters:
  • r - http request - not used
  • client_base - server_id for cache key
  • ds - ObjectWrapper for cache key
  • data - Data to cache
Returns: True

getDatasetContents(self, r, client_base, ds)

source code 

Gets data from the json cache using 'contents' as context

Parameters:
  • r - http request - not used
  • client_base - server_id for cache key
  • ds - ObjectWrapper for cache key
Returns: String or None

clearDatasetContents(self, r, client_base, ds)

source code 

Clears data from the json cache using 'contents' as context

Parameters:
  • r - http request - not used
  • client_base - server_id for cache key
  • ds - ObjectWrapper for cache key
Returns: True