| Home | Trees | Indices | Help |
|
|---|
|
|
Entropy asynchronous and synchronous cache writer and reader. This class is a Singleton and contains a thread doing the cache writes asynchronously, thus it must be stopped before your application is terminated calling the stop() method.
Sample code:
>>> # import module >>> from entropy.cache import EntropyCacher ... >>> # first EntropyCacher load, start it >>> cacher = EntropyCacher() >>> cacher.start() ... >>> # now store something into its cache >>> cacher.push('my_identifier1', [1, 2, 3]) >>> # now store something synchronously >>> cacher.push('my_identifier2', [1, 2, 3], async = False) ... >>> # now flush all the caches to disk, and make sure all >>> # is written >>> cacher.sync(wait = True) ... >>> # now fetch something from the cache >>> data = cacher.pop('my_identifier1') [1, 2, 3] ... >>> # now discard all the cached (async) writes >>> cacher.discard() ... >>> # and stop EntropyCacher >>> cacher.stop()
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
| None |
|
||
|
|||
| None |
|
||
| Python object |
|
||
|
Inherited from Inherited from |
|||
| Static Methods | |
|
Inherited from |
| Properties | |
|
Inherited from |
| Method Details |
Singleton overloaded method. Equals to __init__. This is the place where all the properties initialization takes place. |
This is the method used to start the asynchronous cache writer but also the whole cacher. If this method is not called, the instance will always trash and cache write request.
|
Return whether start is called or not. This equals to checking if the cacher is running, thus is writing cache to disk.
|
This method stops the execution of the cacher, which won't accept cache writes anymore. The thread responsible of writing to disk is stopped here and the Cacher will be back to being inactive. A watchdog will avoid the thread to freeze the call if the write buffer is overloaded.
|
This method can be called anytime and forces the instance to flush all the cache writes queued to disk. If wait == False a watchdog prevents this call to get stuck in case of write buffer overloads.
|
This method makes buffered cache to be discarded synchronously.
|
This is the place where data is either added to the write queue or written to disk (if async == False) only and only if start() method has been called.
|
This is the place where data is retrieved from cache. You must know the cache identifier used when push() was called.
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Aug 5 16:58:52 2009 | http://epydoc.sourceforge.net |