sharing persisten cache between modules

Steve Holden steve at holdenweb.com
Mon Oct 23 13:02:35 EDT 2006


Bart Ogryczak wrote:
> Fredrik Lundh wrote:
> 
>>Bart Ogryczak wrote:
>>
>>
>>>I´ve got a problem creating persistent cache, that would be shared
>>>between modules. There a supermodule, which calls submodules. I´d like
>>>submodules to use cache created in the supermodule. The only way I see
>>>right now, is to pass it as function argument, but that would require a
>>>change in API, which I´d prefer to avoid. Is this the only way?
>>
>>does "module" mean Python module?
> 
> 
> Yes it does.
> 
> 
>>why not just put the cache management
>>code in a module that's imported by any submodule that wants to use it ?
> 
> 
> The problem is, that then it is not shared. If I do it like that, each
> module has it´s own copy of the cache. Maybe I´m doing something
> wrong. I´ve made a cache module, imported it in each of the
> submodules. I don´t know how to make the data "static".
> 
No, it doesn't. At least, not if the cache is global to the module 
that's imported by all the other ones.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list