10
10
class ResqueScheduler
11
11
{
12
12
const VERSION = "0.1 " ;
13
-
13
+
14
14
/**
15
15
* Enqueue a job in a given number of seconds from now.
16
16
*
@@ -45,7 +45,7 @@ public static function enqueueAt($at, $queue, $class, $args = array())
45
45
46
46
$ job = self ::jobToHash ($ queue , $ class , $ args );
47
47
self ::delayedPush ($ at , $ job );
48
-
48
+
49
49
Resque_Event::trigger ('afterSchedule ' , array (
50
50
'at ' => $ at ,
51
51
'queue ' => $ queue ,
@@ -87,7 +87,7 @@ public static function getDelayedQueueScheduleSize()
87
87
*/
88
88
public static function getDelayedTimestampSize ($ timestamp )
89
89
{
90
- $ timestamp = self ::toTimestamp ($ timestamp );
90
+ $ timestamp = self ::getTimestamp ($ timestamp );
91
91
return Resque::redis ()->llen ('delayed: ' . $ timestamp , $ timestamp );
92
92
}
93
93
@@ -144,7 +144,7 @@ public static function removeDelayedJobFromTimestamp($timestamp, $queue, $class,
144
144
145
145
return $ count ;
146
146
}
147
-
147
+
148
148
/**
149
149
* Generate hash of all job properties to be saved in the scheduled queue.
150
150
*
@@ -194,7 +194,7 @@ private static function getTimestamp($timestamp)
194
194
if ($ timestamp instanceof DateTime) {
195
195
$ timestamp = $ timestamp ->getTimestamp ();
196
196
}
197
-
197
+
198
198
if ((int )$ timestamp != $ timestamp ) {
199
199
throw new ResqueScheduler_InvalidTimestampException (
200
200
'The supplied timestamp value could not be converted to an integer. '
@@ -224,15 +224,15 @@ public static function nextDelayedTimestamp($at = null)
224
224
else {
225
225
$ at = self ::getTimestamp ($ at );
226
226
}
227
-
227
+
228
228
$ items = Resque::redis ()->zrangebyscore ('delayed_queue_schedule ' , '-inf ' , $ at , array ('limit ' => array (0 , 1 )));
229
229
if (!empty ($ items )) {
230
230
return $ items [0 ];
231
231
}
232
-
232
+
233
233
return false ;
234
- }
235
-
234
+ }
235
+
236
236
/**
237
237
* Pop a job off the delayed queue for a given timestamp.
238
238
*
@@ -243,9 +243,9 @@ public static function nextItemForTimestamp($timestamp)
243
243
{
244
244
$ timestamp = self ::getTimestamp ($ timestamp );
245
245
$ key = 'delayed: ' . $ timestamp ;
246
-
246
+
247
247
$ item = json_decode (Resque::redis ()->lpop ($ key ), true );
248
-
248
+
249
249
self ::cleanupTimestamp ($ key , $ timestamp );
250
250
return $ item ;
251
251
}
@@ -265,7 +265,7 @@ private static function validateJob($class, $queue)
265
265
else if (empty ($ queue )) {
266
266
throw new Resque_Exception ('Jobs must be put in a queue. ' );
267
267
}
268
-
268
+
269
269
return true ;
270
270
}
271
271
}
0 commit comments