On Aug 20, 2012, at 7:26 AM, njh@bandsman.co.uk via RT wrote:
Show quoted text> Queue: CHI
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=79100 >
>
>
>> Ok, could you be more specific about your driver? Is there a way that the cleanup could be built into the backend itself (the way we do with tempdir()), rather than trying to go through and clear all namespaces, etc.?
>
> See CHI::Driver::SharedMem for more information.
>
Ok. So I think you want to do the equivalent of what the other modules do with tempdir(), that is, create a shared memory segment that is guaranteed to be cleaned up at the end of the process. I don't know much about shared memory but maybe something like:
END { IPC::SharedMem->new(12344321, …)->remove(); }
Of course there's nothing you can do in case of a kill -9, server crash, etc.
I will add something to CHI::Driver::Development about how each driver test is responsible for cleaning up its backend.
IMO arranging things so that the backend can be cleaned up in one go is much more likely to succeed than trying to remove all the namespaces and keys that were touched during the tests.
Unrelated note: In your docs, looks like you need to format this section for code:
Number of bytes in the cache [ int ] 'cache' => { 'namespace1' => { 'key1' => 'value1', 'key2' -> 'value2', ... } 'namespace2' => { 'key1' => 'value3', 'key3' => 'value2', ... } … }
e.g. see how it displays on
https://metacpan.org/module/CHI::Driver::SharedMem
Best
Jon