31 Aug 2016 04:43:51 UTC
- Distribution: CHI-Driver-Redis-SortedSet
- Module version: 0.01
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Issues (0)
- Testers (523 / 2 / 25)
- KwaliteeBus factor: 1
- % Coverage
- License: perl_5
- Perl: v5.8.5
- Activity24 month
- Download (11.94KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionATANCASIS Arnold Tan Casis
- SEE ALSO
CHI::Driver::Redis::SortedSet - Redis driver for CHI with proper expiration of namespace keys
use CHI; my $cache = CHI->new( driver => 'Redis::SortedSet', namespace => 'products', server => '127.0.0.1:6379', debug => 0 );
Extends CHI::Driver::Redis to address memory leak issues from an unbound
setholding the namespace members. This module implements the fix as suggested in a feature request by Pieter Noordhuis as outlined here.
The expiration mechanism is implemented as a lazy cleanup, transparently invoked everytime
storeis called via
Please note that this is not backwards compatible with existing Redis datasets that have already been populated with entries via the CHI::Driver::Redis module due to the underlying change in the data type holding the list of all keys in the namespace as retrieved thru
Congratulations! You're in the best position to use this module instead of CHI::Driver::Redis if memory usage can become an issue based on your setup and use case.
I've been using CHI::Driver::Redis. How do I migrate to this new module?
The FLUSHDB command should first be issued. Please note that this will drop all existing keys and cached data and so is a destructive procedure.
Why not make the driver backwards compatible with CHI::Driver::Redis?
Yes, that's very much possible. And should likewise not be too costly as it will only have to involve a one-time transparently-invoked migration to migrate all previously-defined namespace members from the original
sorted set, with expiration values set from each key's TTL.
However, it would be prudent that the memory leak is an actual issue being experienced by the developer before using this module. At this point, the developer should first be aware of the subtle changes which will happen under the hood.
As such, the author has made a judgment call to make this a conscious decision on the developer's part.
Why not send a pull request and incorporate this into CHI::Driver::Redis?
The author will first collaborate with the authors of CHI::Driver::Redis and if deemed acceptable, merge the modifications into the original code base so we won't have to deal with the confusion of having multiple CHI drivers doing pretty much the same thing.
Otherwise, this module will continue to exist on a different namespace to provide developers with this option.
CHI::purge()is not implemented, just like CHI::Driver::Redis.
Arnold Tan Casis <email@example.com>
This is based on the work by Cory G Watson <gphat at cpan.org> and Ian Burrell <firstname.lastname@example.org> so all attributions should go to them.
Likewise, the fix implemented in this module is inspired by the suggestion of Pieter Noordhuis <email@example.com>.
Copyright 2016- Arnold Tan Casis
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install CHI::Driver::Redis::SortedSet, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install CHI::Driver::Redis::SortedSet
For more information on module installation, please visit the detailed CPAN module installation guide.