Skip to content

Commit f1d4e4d

Browse files
feat(stream mode): Do not save bypass decision in cache
1 parent 9d14648 commit f1d4e4d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/AbstractCache.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,14 @@ protected function defferUpdateCacheConfig(array $config): void
348348
protected function formatRemediationFromDecision(?array $decision): array
349349
{
350350
if (!$decision) {
351-
/**
352-
* In stream mode we consider a clean IP forever... until the next resync.
353-
* in this case, forever is 10 years as PHP_INT_MAX will cause trouble with the Memcached Adapter
354-
* (int to float unwanted conversion)
355-
*
356-
*/
357-
$duration = $this->streamMode ? 315360000 : $this->cacheExpirationForCleanIp;
351+
$duration = $this->cacheExpirationForCleanIp;
358352

359353
return [Constants::REMEDIATION_BYPASS, time() + $duration, 0];
360354
}
361355

362356
$duration = self::parseDurationToSeconds($decision['duration']);
363357

364-
// Don't set a max duration in stream mode to avoid bugs. Only the stream update has to change the cache state.
358+
// In stream mode, only the stream update has to change the cache state.
365359
if (!$this->streamMode) {
366360
$duration = min($this->cacheExpirationForBadIp, $duration);
367361
}
@@ -432,6 +426,10 @@ protected function miss(string $value, string $cacheScope): string
432426
]);
433427
}
434428
}
429+
// In stream mode, we do not save bypass decision in cache
430+
if($this->streamMode && !$decisions){
431+
return Constants::REMEDIATION_BYPASS;
432+
}
435433

436434
return $this->saveRemediationsForCacheKey($decisions, $cacheKey);
437435
}

0 commit comments

Comments
 (0)