r73868 - in /branches/upstream/libchi-perl/current: ./ lib/ lib/CHI/ lib/CHI/Driver/ lib/CHI/Driver/Base/ lib/CHI/Driver/Role/ lib/CHI/t/ lib/CHI/t/Driver/ lib/CHI/t/Driver/Subcache/ lib/CHIx/

carnil at users.alioth.debian.org carnil at users.alioth.debian.org
Sat Apr 30 19:55:50 UTC 2011


Author: carnil
Date: Sat Apr 30 19:55:43 2011
New Revision: 73868

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=73868
Log:
[svn-upgrade] new version libchi-perl (0.47)

Added:
    branches/upstream/libchi-perl/current/lib/CHIx/
    branches/upstream/libchi-perl/current/lib/CHIx/DecayedSet.pm
Modified:
    branches/upstream/libchi-perl/current/Changes
    branches/upstream/libchi-perl/current/MANIFEST
    branches/upstream/libchi-perl/current/META.json
    branches/upstream/libchi-perl/current/META.yml
    branches/upstream/libchi-perl/current/Makefile.PL
    branches/upstream/libchi-perl/current/README
    branches/upstream/libchi-perl/current/lib/CHI.pm
    branches/upstream/libchi-perl/current/lib/CHI/Benchmarks.pod
    branches/upstream/libchi-perl/current/lib/CHI/CacheObject.pm
    branches/upstream/libchi-perl/current/lib/CHI/Constants.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/Base/CacheContainer.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/CacheCache.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/Development.pod
    branches/upstream/libchi-perl/current/lib/CHI/Driver/FastMmap.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/File.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/Memory.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/Metacache.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/Null.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/RawMemory.pm
    branches/upstream/libchi-perl/current/lib/CHI/Driver/Role/Universal.pm
    branches/upstream/libchi-perl/current/lib/CHI/Stats.pm
    branches/upstream/libchi-perl/current/lib/CHI/t/Driver.pm
    branches/upstream/libchi-perl/current/lib/CHI/t/Driver/RawMemory.pm
    branches/upstream/libchi-perl/current/lib/CHI/t/Driver/Subcache/l1_cache.pm

Modified: branches/upstream/libchi-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/Changes?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/Changes (original)
+++ branches/upstream/libchi-perl/current/Changes Sat Apr 30 19:55:43 2011
@@ -1,6 +1,12 @@
 Revision history for CHI
 
 ** denotes an incompatible change
+
+0.47  Apr 28, 2011
+
+* Improvements
+  - Allow compute() to take get options - expire_if and busy_lock
+  - Add atomic operations: add, append, replace (alpha)
 
 0.46  Apr 22, 2011
 

Modified: branches/upstream/libchi-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/MANIFEST?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/MANIFEST (original)
+++ branches/upstream/libchi-perl/current/MANIFEST Sat Apr 30 19:55:43 2011
@@ -73,6 +73,7 @@
 lib/CHI/t/Subcache.pm
 lib/CHI/t/Subclass.pm
 lib/CHI/t/Util.pm
+lib/CHIx/DecayedSet.pm
 t/00-load.t
 t/Bugs.t
 t/Constants.t

Modified: branches/upstream/libchi-perl/current/META.json
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/META.json?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/META.json (original)
+++ branches/upstream/libchi-perl/current/META.json Sat Apr 30 19:55:43 2011
@@ -77,6 +77,6 @@
          "web" : "https://github.com/jonswar/perl-chi"
       }
    },
-   "version" : "0.46"
+   "version" : "0.47"
 }
 

Modified: branches/upstream/libchi-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/META.yml?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/META.yml (original)
+++ branches/upstream/libchi-perl/current/META.yml Sat Apr 30 19:55:43 2011
@@ -50,4 +50,4 @@
 resources:
   bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=CHI
   repository: git://github.com/jonswar/perl-chi.git
-version: 0.46
+version: 0.47

Modified: branches/upstream/libchi-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/Makefile.PL?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/Makefile.PL (original)
+++ branches/upstream/libchi-perl/current/Makefile.PL Sat Apr 30 19:55:43 2011
@@ -44,7 +44,7 @@
     'Time::Duration::Parse' => '0.03',
     'Try::Tiny' => '0.05'
   },
-  'VERSION' => '0.46',
+  'VERSION' => '0.47',
   'test' => {
     'TESTS' => 't/*.t'
   }

Modified: branches/upstream/libchi-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/README?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/README (original)
+++ branches/upstream/libchi-perl/current/README Sat Apr 30 19:55:43 2011
@@ -2,7 +2,7 @@
     CHI - Unified cache handling interface
 
 VERSION
-    version 0.46
+    version 0.47
 
 SYNOPSIS
         use CHI;

Modified: branches/upstream/libchi-perl/current/lib/CHI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI;
 BEGIN {
-  $CHI::VERSION = '0.46';
+  $CHI::VERSION = '0.47';
 }
 use 5.006;
 use Carp;
@@ -93,7 +93,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 
@@ -341,7 +341,8 @@
 =item serializer [STRING|HASHREF|OBJECT]
 
 An object to use for serializing data before storing it in the cache, and
-deserializing data after retrieving it from the cache.
+deserializing data after retrieving it from the cache. Only references will be
+serialized; plain scalars will be placed in the cache as-is.
 
 If this is a string, a L<Data::Serializer|Data::Serializer> object will be
 created, with the string passed as the 'serializer' option and raw=1. Common
@@ -471,18 +472,25 @@
 
 =back
 
-=item compute( $key, $set_options, $code )
+=item compute( $key, $options, $code )
 
 Combines the C<get> and C<set> operations in a single call. Attempts to get
 I<$key>; if successful, returns the value. Otherwise, calls I<$code> and uses
 the return value as the new value for I<$key>, which is then returned.
-I<$set_options> is a scalar or hash reference, used as the third argument to
-set.
+
+I<$options> is a scalar or hash reference. If a scalar, it is treated as the
+C<expires_in> duration and passed as the third argument to C<set>. If it is a
+hash reference, it may contain name/value pairs for both C<get> and C<set>.
+e.g.
 
     $cache->compute($key, '5min', sub {
         # compute and return value for $key here
     });
 
+    $cache->compute($key, { expires_in => '5min', expire_if => sub { ... } }, sub {
+        # compute and return value for $key here
+    });
+
 This method will eventually support the ability to recompute a value in the
 background just before it actually expires, so that users are not impacted by
 recompute time.
@@ -535,6 +543,50 @@
 Returns a L<CHI::CacheObject|CHI::CacheObject> object containing data about the
 entry associated with I<$key>, or undef if no such key exists. The object will
 be returned even if the entry has expired, as long as it has not been removed.
+
+=back
+
+=head2 Atomic operations (ALPHA)
+
+These methods combine both reading and writing of a cache entry in a single
+operation. The names and behaviors were adapted from
+L<memcached|http://memcached.org/>.
+
+Some drivers (e.g.
+L<CHI::Driver::Memcached::libmemcached|Memcached::libmemcached>,
+L<CHI::Driver::DBI|DBI>) may implement these as truly atomic operations, and
+will be documented thusly.  The default implementations are not atomic: the get
+and set occur discretely and another process could potentially modify the cache
+in between them.
+
+These operations are labelled ALPHA because we haven't yet figured out how they
+integrate with other CHI features, in particular L</SUBCACHES>. APIs and
+behavior may change.
+
+=over
+
+=item add( $key, $data, [$expires_in | "now" | "never" | options] )
+
+Do a L<set>, but only if I<$key> is not L<valid|is_valid> in the cache.
+
+=item replace( $key, $data, [$expires_in | "now" | "never" | options] )
+
+Do a L<set>, but only if I<$key> is L<valid|is_valid> in the cache.
+
+=item append( $key, $new_data)
+
+Append I<$new_data> to whatever value is currently associated with I<$key>.
+Does not modify expiration or other metadata; if I<$key> exists but is expired,
+it will remain expired. Has no effect if I<$key> does not exist in the cache.
+
+This is intended for simple string values only. For efficiency's sake, CHI
+won't attempt to check for, or handle, the case where data is
+L<serialized|serializer> or L<compressed|compress_threshold>; the new data will
+simply be appended, and an error will most probably occur when you try to
+retrieve the value.
+
+If you use a driver with the non-atomic (default) implementation, some appends
+may be lost due to race conditions.
 
 =back
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Benchmarks.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Benchmarks.pod?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Benchmarks.pod (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Benchmarks.pod Sat Apr 30 19:55:43 2011
@@ -9,7 +9,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/CacheObject.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/CacheObject.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/CacheObject.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/CacheObject.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::CacheObject;
 BEGIN {
-  $CHI::CacheObject::VERSION = '0.46';
+  $CHI::CacheObject::VERSION = '0.47';
 }
 use CHI::Constants qw(CHI_Max_Time);
 use Encode;
@@ -180,7 +180,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Constants.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Constants.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Constants.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Constants.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Constants;
 BEGIN {
-  $CHI::Constants::VERSION = '0.46';
+  $CHI::Constants::VERSION = '0.47';
 }
 use strict;
 use warnings;
@@ -28,7 +28,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver;
 BEGIN {
-  $CHI::Driver::VERSION = '0.46';
+  $CHI::Driver::VERSION = '0.47';
 }
 use Carp;
 use CHI::CacheObject;
@@ -384,15 +384,22 @@
     my $key  = shift;
 
     # Allow these in either order for backward compatibility
-    my ( $code, $set_options ) =
+    my ( $code, $options ) =
       ( ref( $_[0] ) eq 'CODE' ) ? ( $_[0], $_[1] ) : ( $_[1], $_[0] );
 
     croak "must specify key and code" unless defined($key) && defined($code);
 
-    my $value = $self->get($key);
+    my %get_options =
+      ( ref($options) eq 'HASH' )
+      ? (
+        map { exists( $options->{$_} ) ? ( $_, delete( $options->{$_} ) ) : () }
+          qw(expire_if busy_lock)
+      )
+      : ();
+    my $value = $self->get( $key, %get_options );
     if ( !defined $value ) {
         $value = $code->();
-        $self->set( $key, $value, $set_options );
+        $self->set( $key, $value, $options );
     }
     return $value;
 }
@@ -425,6 +432,35 @@
     my ($self) = @_;
 
     return !$self->get_keys();
+}
+
+#
+# (SEMI-) ATOMIC OPERATIONS
+#
+
+sub add {
+    my $self = shift;
+    my $key  = shift;
+
+    if ( !$self->is_valid($key) ) {
+        $self->set( $key, @_ );
+    }
+}
+
+sub append {
+    my ( $self, $key, $new ) = @_;
+
+    my $current = $self->fetch($key) or return undef;
+    $self->store( $key, $current . $new );
+}
+
+sub replace {
+    my $self = shift;
+    my $key  = shift;
+
+    if ( $self->is_valid($key) ) {
+        $self->set( $key, @_ );
+    }
 }
 
 #
@@ -650,7 +686,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/Base/CacheContainer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/Base/CacheContainer.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/Base/CacheContainer.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/Base/CacheContainer.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::Base::CacheContainer;
 BEGIN {
-  $CHI::Driver::Base::CacheContainer::VERSION = '0.46';
+  $CHI::Driver::Base::CacheContainer::VERSION = '0.47';
 }
 use Moose;
 use Moose::Util::TypeConstraints;
@@ -62,7 +62,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/CacheCache.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/CacheCache.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/CacheCache.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/CacheCache.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::CacheCache;
 BEGIN {
-  $CHI::Driver::CacheCache::VERSION = '0.46';
+  $CHI::Driver::CacheCache::VERSION = '0.47';
 }
 use Cache::Cache;
 use Carp;
@@ -47,7 +47,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/Development.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/Development.pod?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/Development.pod (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/Development.pod Sat Apr 30 19:55:43 2011
@@ -9,7 +9,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/FastMmap.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/FastMmap.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/FastMmap.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/FastMmap.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::FastMmap;
 BEGIN {
-  $CHI::Driver::FastMmap::VERSION = '0.46';
+  $CHI::Driver::FastMmap::VERSION = '0.47';
 }
 use Carp;
 use Cache::FastMmap;
@@ -89,7 +89,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/File.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/File.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/File.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/File.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::File;
 BEGIN {
-  $CHI::Driver::File::VERSION = '0.46';
+  $CHI::Driver::File::VERSION = '0.47';
 }
 use Carp;
 use Cwd qw(realpath cwd);
@@ -248,7 +248,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/Memory.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/Memory.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/Memory.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/Memory.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::Memory;
 BEGIN {
-  $CHI::Driver::Memory::VERSION = '0.46';
+  $CHI::Driver::Memory::VERSION = '0.47';
 }
 use Carp qw(cluck croak);
 use CHI::Constants qw(CHI_Meta_Namespace);
@@ -105,7 +105,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/Metacache.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/Metacache.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/Metacache.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/Metacache.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::Metacache;
 BEGIN {
-  $CHI::Driver::Metacache::VERSION = '0.46';
+  $CHI::Driver::Metacache::VERSION = '0.47';
 }
 use CHI::Constants qw(CHI_Meta_Namespace);
 use Moose;
@@ -66,7 +66,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/Null.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/Null.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/Null.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/Null.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::Null;
 BEGIN {
-  $CHI::Driver::Null::VERSION = '0.46';
+  $CHI::Driver::Null::VERSION = '0.47';
 }
 use Moose;
 use strict;
@@ -28,7 +28,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/RawMemory.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/RawMemory.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/RawMemory.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/RawMemory.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::RawMemory;
 BEGIN {
-  $CHI::Driver::RawMemory::VERSION = '0.46';
+  $CHI::Driver::RawMemory::VERSION = '0.47';
 }
 use Moose;
 use strict;
@@ -9,6 +9,12 @@
 extends 'CHI::Driver::Memory';
 
 has 'serializer' => ( is => 'ro', default => undef, init_arg => undef );
+
+sub append {
+    my ( $self, $key, $new ) = @_;
+
+    return "append not yet supported in this driver";
+}
 
 __PACKAGE__->meta->make_immutable();
 
@@ -24,7 +30,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Driver/Role/Universal.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Driver/Role/Universal.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Driver/Role/Universal.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Driver/Role/Universal.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Driver::Role::Universal;
 BEGIN {
-  $CHI::Driver::Role::Universal::VERSION = '0.46';
+  $CHI::Driver::Role::Universal::VERSION = '0.47';
 }
 use CHI::Constants qw(CHI_Meta_Namespace);
 use Moose::Role;
@@ -15,12 +15,14 @@
     return grep { $_ ne CHI_Meta_Namespace } $self->$orig(@_);
 };
 
-around 'remove' => sub {
-    my ( $orig, $self, $key ) = @_;
+foreach my $method (qw(remove append)) {
+    around $method => sub {
+        my ( $orig, $self, $key, @rest ) = @_;
 
-    # Call transform_key before passing to remove
-    return $self->$orig( $self->transform_key($key) );
-};
+        # Call transform_key before passing to method
+        return $self->$orig( $self->transform_key($key), @rest );
+    };
+}
 
 1;
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/Stats.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/Stats.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/Stats.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/Stats.pm Sat Apr 30 19:55:43 2011
@@ -1,6 +1,6 @@
 package CHI::Stats;
 BEGIN {
-  $CHI::Stats::VERSION = '0.46';
+  $CHI::Stats::VERSION = '0.47';
 }
 use Log::Any qw($log);
 use Moose;
@@ -137,7 +137,7 @@
 
 =head1 VERSION
 
-version 0.46
+version 0.47
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libchi-perl/current/lib/CHI/t/Driver.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/t/Driver.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/t/Driver.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/t/Driver.pm Sat Apr 30 19:55:43 2011
@@ -1663,15 +1663,28 @@
     my $cache = $self->{cache};
 
     # Test current arg order and pre-0.40 arg order
-    my $expire_time = time + 10;
-    my @orig = ( { expires_at => $expire_time }, sub { 'bar' } );
-    foreach my $args ( [@orig], [ reverse(@orig) ] ) {
+    foreach my $iter ( 0 .. 1 ) {
+        my $count       = 5;
+        my $expire_time = time + 10;
+        my @args1       = ( { expires_at => $expire_time }, sub { $count++ } );
+        my @args2       = (
+            {
+                expire_if => sub { 1 }
+            },
+            sub { $count++ }
+        );
+        if ($iter) {
+            @args1 = reverse(@args1);
+            @args2 = reverse(@args2);
+        }
         $cache->clear;
         is( $cache->get('foo'), undef, "miss" );
-        $cache->compute( 'foo', @$args );
-        is( $cache->get('foo'), 'bar', "hit" );
+        is( $cache->compute( 'foo', @args1 ), 5, "compute - 5" );
+        is( $cache->get('foo'), 5, "hit - 5" );
         is( $cache->get_object('foo')->expires_at, $expire_time,
             "expire time" );
+        is( $cache->compute( 'foo', @args2 ), 6, "compute - 6" );
+        is( $cache->get('foo'), 6, "hit - 6" );
     }
 }
 
@@ -1734,4 +1747,64 @@
     }
 }
 
+sub test_append : Tests {
+    my $self  = shift;
+    my $cache = $self->{cache};
+    my ( $key, $value ) =
+      ( $self->{keys}->{arrayref}, $self->{values}->{medium} );
+
+    # Appending to non-existent key has no effect
+    #
+    $cache->append( $key, $value );
+    ok( !$cache->get($key) );
+
+    ok( $cache->set( $key, $value ) );
+    $cache->append( $key, $value );
+    is( $cache->get($key), $value . $value );
+    $cache->append( $key, $value );
+    is( $cache->get($key), $value . $value . $value );
+}
+
+sub test_add : Tests {
+    my $self  = shift;
+    my $cache = $self->{cache};
+    my ( $key, $value ) =
+      ( $self->{keys}->{arrayref}, $self->{values}->{medium} );
+
+    my $t = time();
+
+    $cache->add( $key, $value, { expires_at => $t + 100 } );
+    is( $cache->get($key),                    $value,   "get" );
+    is( $cache->get_object($key)->expires_at, $t + 100, "expires_at" );
+
+    $cache->add( $key, $value . $value, { expires_at => $t + 200 } );
+    is( $cache->get($key), $value, "get (after add)" );
+    is( $cache->get_object($key)->expires_at,
+        $t + 100, "expires_at (after add)" );
+
+    $cache->remove($key);
+    $cache->add( $key, $value . $value, { expires_at => $t + 200 } );
+    is( $cache->get($key), $value . $value, "get (after expire and add)" );
+    is( $cache->get_object($key)->expires_at,
+        $t + 200, "expires_at (after expire and add)" );
+}
+
+sub test_replace : Tests {
+    my $self  = shift;
+    my $cache = $self->{cache};
+    my ( $key, $value ) =
+      ( $self->{keys}->{arrayref}, $self->{values}->{medium} );
+
+    my $t = time();
+
+    $cache->replace( $key, $value, { expires_at => $t + 100 } );
+    ok( !$cache->get_object($key), "get" );
+
+    $cache->set( $key, $value . $value, { expires_at => $t + 200 } );
+    $cache->replace( $key, $value, { expires_at => $t + 100 } );
+    is( $cache->get($key), $value, "get (after replace)" );
+    is( $cache->get_object($key)->expires_at,
+        $t + 100, "expires_at (after replace)" );
+}
+
 1;

Modified: branches/upstream/libchi-perl/current/lib/CHI/t/Driver/RawMemory.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/t/Driver/RawMemory.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/t/Driver/RawMemory.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/t/Driver/RawMemory.pm Sat Apr 30 19:55:43 2011
@@ -28,6 +28,7 @@
 
 # Would need tweaking to pass
 #
+sub test_append                        { }
 sub test_compress_threshold            { }
 sub test_custom_discard_policy         { }
 sub test_lru_discard                   { }

Modified: branches/upstream/libchi-perl/current/lib/CHI/t/Driver/Subcache/l1_cache.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHI/t/Driver/Subcache/l1_cache.pm?rev=73868&op=diff
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHI/t/Driver/Subcache/l1_cache.pm (original)
+++ branches/upstream/libchi-perl/current/lib/CHI/t/Driver/Subcache/l1_cache.pm Sat Apr 30 19:55:43 2011
@@ -52,4 +52,7 @@
 
 }
 
+# not working yet
+sub test_append { }
+
 1;

Added: branches/upstream/libchi-perl/current/lib/CHIx/DecayedSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libchi-perl/current/lib/CHIx/DecayedSet.pm?rev=73868&op=file
==============================================================================
--- branches/upstream/libchi-perl/current/lib/CHIx/DecayedSet.pm (added)
+++ branches/upstream/libchi-perl/current/lib/CHIx/DecayedSet.pm Sat Apr 30 19:55:43 2011
@@ -1,0 +1,17 @@
+package CHIx::DecayedSet;
+use Moose;
+
+has 'cache'       => ( isa => 'CHI::Types::Cache' );
+has 'decays_in'   => ( isa => 'CHI::Types::Duration' );
+has 'granularity' => ( isa => 'CHI::Types::Duration' );
+
+sub insert {
+    my ($value) = @_;
+
+    my $key =;
+    $self->cache->;
+}
+
+__PACKAGE__->meta->make_immutable();
+
+1;




More information about the Pkg-perl-cvs-commits mailing list