Exemple #1
0
 protected function __construct()
 {
     $this->m = \jmvc::redis();
     self::$stats = array('hits' => 0, 'misses' => 0, 'writes' => 0, 'keys' => array());
 }
Exemple #2
0
 /**
  * Place a job in the JMVC job queue. Requires job-worker.php to be running
  * @param $class The model name to call or instantiate
  * @param $method The model class method to call
  * @param $obj_id Optional; if provided, the object with that ID will be instantiated, otherwise $method will be called statically.
  * @param $args Arguments to be passed to $method
  * @param $priority Can be either 'high' or 'low'
  */
 public static function defer($class, $method, $obj_id = null, $args = array(), $priority = 'low')
 {
     if (!in_array($priority, array('high', 'low'))) {
         throw new \Exception('Invalid priority type: ' . $priority);
     }
     $r = \jmvc::redis();
     $job = array('class' => $class, 'method' => $method, 'obj_id' => $obj_id, 'args' => $args, 'created' => time());
     $r->rpush('JMVC:jobs:' . $priority, json_encode($job));
 }