Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67bd238

Browse files
[Cache] fix Redis support on 32b arch
1 parent 6d688f6 commit 67bd238

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ install:
2121
- cd ext
2222
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.18-7.1-ts-vc14-x86.zip
2323
- 7z x php_apcu-5.1.18-7.1-ts-vc14-x86.zip -y >nul
24+
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-5.1.1-7.1-ts-vc14-x86.zip
25+
- 7z x php_redis-5.1.1-7.1-ts-vc14-x86.zip -y >nul
2426
- cd ..
2527
- copy /Y php.ini-development php.ini-min
2628
- echo memory_limit=-1 >> php.ini-min
@@ -36,6 +38,7 @@ install:
3638
- echo opcache.enable_cli=1 >> php.ini-max
3739
- echo extension=php_openssl.dll >> php.ini-max
3840
- echo extension=php_apcu.dll >> php.ini-max
41+
- echo extension=php_redis.dll >> php.ini-max
3942
- echo apc.enable_cli=1 >> php.ini-max
4043
- echo extension=php_intl.dll >> php.ini-max
4144
- echo extension=php_mbstring.dll >> php.ini-max
@@ -54,6 +57,7 @@ install:
5457
- SET COMPOSER_ROOT_VERSION=%SYMFONY_VERSION%.x-dev
5558
- php composer.phar update --no-progress --ansi
5659
- php phpunit install
60+
- choco install memurai-developer
5761

5862
test_script:
5963
- SET X=0

src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ public function get(): ?array
141141
if ($this->autoSetup) {
142142
$this->setup();
143143
}
144+
$now = 1000 * microtime(true);
144145

145146
try {
146-
$queuedMessageCount = $this->connection->zcount($this->queue, 0, $this->getCurrentTimeInMilliseconds());
147+
$queuedMessageCount = $this->connection->zcount($this->queue, 0, $now);
147148
} catch (\RedisException $e) {
148149
throw new TransportException($e->getMessage(), 0, $e);
149150
}
@@ -164,7 +165,7 @@ public function get(): ?array
164165
$this->add(
165166
$queuedMessage['body'],
166167
$queuedMessage['headers'],
167-
$time - $this->getCurrentTimeInMilliseconds()
168+
$time - $now
168169
);
169170
}
170171
}
@@ -255,7 +256,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
255256
}
256257

257258
try {
258-
if ($delayInMs > 0) { // the delay could be smaller 0 in a queued message
259+
if ($delayInMs > 0) { // the delay could be smaller than 0 in a queued message
259260
$message = json_encode([
260261
'body' => $body,
261262
'headers' => $headers,
@@ -267,7 +268,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): void
267268
throw new TransportException(json_last_error_msg());
268269
}
269270

270-
$score = $this->getCurrentTimeInMilliseconds() + $delayInMs;
271+
$score = 1000 * microtime(true) + $delayInMs;
271272
$added = $this->connection->zadd($this->queue, ['NX'], $score, $message);
272273
} else {
273274
$message = json_encode([
@@ -316,11 +317,6 @@ public function setup(): void
316317
$this->autoSetup = false;
317318
}
318319

319-
private function getCurrentTimeInMilliseconds(): int
320-
{
321-
return (int) (microtime(true) * 1000);
322-
}
323-
324320
public function cleanup(): void
325321
{
326322
$this->connection->del($this->stream);

0 commit comments

Comments
 (0)