wa0x6e / Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
MIT License
159 stars 56 forks source link

How to remove a job after scheduling #77

Open hnq90 opened 9 years ago

hnq90 commented 9 years ago

Hello, I'm using scheduler for running some tasks. But sometimes I want to delete some jobs which are scheduled.

I'm doing this way but it didn't work. ResqueScheduler.php

public static function delayedPush($timestamp, $item)
    {
        $timestamp = self::getTimestamp($timestamp);
        $redis = \Resque::redis();

        ### My modification
        // Custom key
        $key = 'task_run_on_sunday_#1';
        $value = 'resque:_schdlr_:1417599060'; // I found this key has job detail
        // I add a custom key in redis
        $redis->hset("job_scheduled_store", $key, $value);

        $redis->rpush(self::QUEUE_NAME . ':' . $timestamp, json_encode($item));
        $redis->zadd(self::QUEUE_NAME, $timestamp, $timestamp);
    }

And If I want to delete task task_run_on_sunday_#1 from scheduler: I delete that key resque:_schdlr_:1417599060 and delete 1417599060 from resque:_schdlr_.

Could anyone help me to resolve this?