madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22904: LJSUP-13604: Local cache [internal]

Committer: sbelyaev
LJSUP-13604: Local cache [internal]
U   trunk/cgi-bin/LJ/LocalCache/Redis.pm
U   trunk/cgi-bin/LJ/LocalCache.pm
Modified: trunk/cgi-bin/LJ/LocalCache/Redis.pm
===================================================================
--- trunk/cgi-bin/LJ/LocalCache/Redis.pm	2012-09-17 11:18:35 UTC (rev 22903)
+++ trunk/cgi-bin/LJ/LocalCache/Redis.pm	2012-09-17 11:32:30 UTC (rev 22904)
@@ -100,10 +100,24 @@
 
     my $result = $connection->set( $key, 
                                    utf8::decode($value) );
-    $connection->expire($key, $expire);
+
+    if ($expire) {
+        $connection->expire($key, $expire);
+    }
+
     return $result;
 }
 
+sub expire {
+    my ($class, $key, $expire) = @_;
+    my $connection = __get_write_conneciton();
+    if (!$connection) {
+        return 0;
+    }
+
+    return $connection->expire($key, $expire);
+}
+
 sub replace {
     my ($class, $key, $value, $expire) = @_;
     return $class->set($key);

Modified: trunk/cgi-bin/LJ/LocalCache.pm
===================================================================
--- trunk/cgi-bin/LJ/LocalCache.pm	2012-09-17 11:18:35 UTC (rev 22903)
+++ trunk/cgi-bin/LJ/LocalCache.pm	2012-09-17 11:32:30 UTC (rev 22904)
@@ -4,6 +4,12 @@
 
 use LJ::ModuleLoader;
 
+# Usage example: 
+#   
+#   LJ::LocalCache::get_cache()->set("ml.${lncode}.${dmid}.${itcode}", $text, 30*60);
+#
+
+
 my @SUBCLASSES = LJ::ModuleLoader->module_subclasses(__PACKAGE__);
 
 my $loaded = 0;
@@ -31,8 +37,13 @@
     return "LJ::LocalCache::$handler";
 }
 
+sub expire {
+    my ($class, $key, $expire) = @_;
+    return 0;
+}
+
 sub get {
-    my ($class,$key) = @_;
+    my ($class, $key) = @_;
     return undef;
 }
 
@@ -49,13 +60,48 @@
 
 sub replace {
     my ($class, $key, $value, $expire) = @_;
-    return undef;
+    return 0;
 }
 
 sub delete {
     my ($class, $key) = @_;
+    return 0;
+}
+
+sub incr {
+    my ($class, $key, $value) = @_;
+    return 0;
+}
+
+sub decr {
+    my ($class, $key, $value) = @_;
+    return 0;
+}
+
+sub exists {
+    my ($class, $key) = @_;
+    return 0;
+}
+
+sub rpush {
+    my ($class, $key, $value) = @_;
+    return 0;
+}
+
+sub lpush {
+    my ($class, $key, $value) = @_;
+    return 0;
+}
+
+sub lpop {
+    my ($class, $key) = @_;
     return undef;
 }
 
+sub rpop {
+    my ($class, $key) = @_;
+    return undef;
+}
+
 1;
 

Tags: livejournal, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments