changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[ljcom] r7574: LJSV-686: remove using 'trylock' and bat...

Committer: vsukhanov
LJSV-686: remove using 'trylock' and batch data uploading to memcached.

U   trunk/bin/worker/latest-posts
Modified: trunk/bin/worker/latest-posts
===================================================================
--- trunk/bin/worker/latest-posts	2009-08-18 09:04:26 UTC (rev 7573)
+++ trunk/bin/worker/latest-posts	2009-08-18 09:13:06 UTC (rev 7574)
@@ -11,41 +11,16 @@
 package LJ::Worker::LatestPosts;
 use base 'TheSchwartz::Worker';
 
-my $lock;
-my $done = 0;
+sub work {
+    my ($class, $job) = @_;
+    my $args = $job->arg;
 
-sub on_prework {
-    return 1 if $lock;  # already have the lock
-    $lock = LJ::locker()->trylock("ljcom-latest-worker")
-        or return 0;
-    LJ::Worker::LatestPosts->_pre_work;
-    $done = 0;
-    return 1;
-}
-
-
-sub on_afterwork {
-    my $did_work = shift;
-    $done++ if $did_work;
-    if ($done > 25 || ! $did_work) {
-        LJ::NewWorker::TheSchwartz::LatestPosts->_post_work;
-        $lock = undef;
-        $done = 0;
-    }
-};
-
-sub _pre_work {
     $LJ::CACHE_RECENTPOSTS_CHANGES = 0;
     $LJ::CACHE_RECENTPOSTS ||= LJ::MemCache::get("blob:ljcom_latestposts2") || [];
 
     $LJ::CACHE_RECENTIMG_CHANGES = 0;
     $LJ::CACHE_RECENTIMG ||= LJ::MemCache::get("blob:ljcom_latestimg") || [];
-}
 
-sub work {
-    my ($class, $job) = @_;
-    my $args = $job->arg;
-
     my $recent = $LJ::CACHE_RECENTPOSTS;
     my $uj = LJ::load_userid($args->{'journalid'});
     my $up = LJ::load_userid($args->{'posterid'});
@@ -83,6 +58,8 @@
         push @$rimg, [ $args->{'img'}, $rp->{journalu}, $args->{'itemid'}, $args->{'anum'} ];
         $LJ::CACHE_RECENTIMG_CHANGES++;
     }
+
+    _post_work();
     $job->completed;
 }
 

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