sharing persisten cache between modules

Bart Ogryczak B.Ogryczak at gmail.com
Mon Oct 23 12:45:33 EDT 2006


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".




More information about the Python-list mailing list