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    => '',
            debug     => 0


    Extends CHI::Driver::Redis to address memory leak issues from an
    unbound set holding 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 store is called via CHI::set().

    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


  I'm starting fresh with a new Redis database. What should I do?


    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 set to a 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 <>


    This is based on the work by Cory G Watson <gphat at> and Ian
    Burrell <> so all attributions should go to them.

    Likewise, the fix implemented in this module is inspired by the
    suggestion of Pieter Noordhuis <>.


    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.