Package Products :: Package CCZSQLMethods :: Module SharedCache
[show private | hide private]
[frames | no frames]

Module Products.CCZSQLMethods.SharedCache

Shared Resource.

Usually, each thread has its own data to minimize interference and to localize synchonization in the transaction commit.

However, this makes it difficult to control such data from a single point. E.g. it is very difficult to invalidate cache entries: while there is no problem for a thread to invalidate entries in its own cache, it is very difficult to do the same with the corresponding caches in the other threads.

'Shared Resource' is a module that manages resources shared by all threads. Such resources can be controlled much more easily. A shared resource provides locking capabilities (via Python s RLock) and performs automatic locking for function calls. Access to non-functions is not protected.

A shared resource is identified by an id. The application is responsible that id s are unique.

Shared resources are not persistent. Currently, they do not support acquisition. This may change however.
Classes
_WrapCallable  
_WrapResource  

Function Summary
  getResource(id, creator, createArguments)
returns a resource for *id*.

Variable Summary
lock _ResourceLock = <thread.lock object at 0x2ae6d0a0>
dict _ResourceMap = {}

Function Details

getResource(id, creator, createArguments=())

returns a resource for *id*.

If such a resource does not yet exist, one is created by calling *creator* with *createArguments*. Note, that *creator* and *createArguments* should only depend on *id* and not any other context, as no object is created, when a resource for *id* already exists.

Variable Details

_ResourceLock

Type:
lock
Value:
<thread.lock object at 0x2ae6d0a0>                                     

_ResourceMap

Type:
dict
Value:
{}                                                                     

Generated by Epydoc 2.0 on Thu Jan 15 23:59:16 2004 http://epydoc.sf.net