Skip to content

Commit

Permalink
2.1.3 (2023-11-15)
Browse files Browse the repository at this point in the history
- Resolved issue with SET EX TTL's using unix-timestamps
  • Loading branch information
idanoo committed Nov 14, 2023
1 parent 0b925b6 commit 948b758
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.1.3 (2023-11-15)
- Resolved issue with SET EX TTL's using unix-timestamps

# 2.1.2 (2023-03-22)
- Update composer packages
- Update git information (GitHub)
Expand Down
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
php-resque: PHP Resque Worker (and Enqueue)
php-resque: PHP Background (Resque) Worker
===========================================

Resque is a Redis-backed library for creating background jobs, placing
Expand Down Expand Up @@ -53,19 +53,9 @@ Composer package inside your project.

If you're not familiar with Composer, please see <http://getcomposer.org/>.

1. Add php-resque to your application's composer.json.
1. Run `composer require idanoo/php-resque`.

```json
{
"require": {
"idanoo/php-resque": "^2.0"
}
}
```

2. Run `composer install`.

3. If you haven't already, add the Composer autoload to your project's
2. If you haven't already, add the Composer autoload to your project's
initialization file. (example)

```sh
Expand Down
4 changes: 2 additions & 2 deletions src/Resque/Job/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function create($id)
\Resque\Resque::redis()->set(
'job:' . $id . ':status',
json_encode($statusPacket),
['ex' => time() + 86400],
['ex' => (86400 * 2)],
);
}

Expand Down Expand Up @@ -106,7 +106,7 @@ public function update($status)
\Resque\Resque::redis()->set(
(string)$this,
json_encode($statusPacket),
['ex' => time() + 86400],
['ex' => (86400 * 2)],
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resque/Stat.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function incr(string $stat, int $by = 1): bool
$set = Resque::redis()->set(
'stat:' . $stat,
$by,
['ex' => time() + 86400, 'nx'],
['ex' => (86400 * 2), 'nx'],
);

// If it already exists, return the incrby value
Expand Down
10 changes: 6 additions & 4 deletions src/Resque/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,17 @@ public function workerPids()

/**
* Register this worker in Redis.
* 48 hour TTL so we don't pollute the db on server termination.
* 48 hour TTL so we don't pollute the redis db on server termination.
*
* @return void
*/
public function registerWorker()
public function registerWorker(): void
{
Resque::redis()->sadd('workers', (string)$this);
Resque::redis()->set(
'worker:' . (string)$this . ':started',
date('D M d H:i:s T Y'),
['ex' => time() + 86400],
['ex' => (86400 * 2)],
);
}

Expand Down Expand Up @@ -535,7 +537,7 @@ public function workingOn(\Resque\Job\Job $job)
Resque::redis()->set(
'worker:' . $job->worker,
$data,
['ex' => time() + 86400],
['ex' => (86400 * 2)],
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Resque/Tests/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testRedisGetSet()
$this->redis->set(
'testKey',
24,
['ex' => time() + 3600],
['ex' => 3600],
);

$val = $this->redis->get("testKey");
Expand Down

0 comments on commit 948b758

Please sign in to comment.