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.
Function Summary |
|
getResource (id,
creator,
createArguments)
returns a resource for *id*. |
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.
-
|