Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass seconds to methods which receive seconds not milliseconds #558

Open
wants to merge 10 commits into
base: 6.5.x
Choose a base branch
from

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Aug 9, 2024

Close: #474

RedisAsynCommand::expire methods takes seconds but we were passing milliseconds.

There are other methods in the Redis API, for example the RedisAsynCommand::pexpire which takes milliseconds. Our tests, were hitting that method. That it is the reason why they were passing.

This PR converts from milliseconds to seconds the methods that require seconds and it adds tests for those code paths.

@sdelamo sdelamo changed the title Issue 474 Pass seconds to methods which receive seconds not milliseconds Aug 9, 2024
Copy link

sonarcloud bot commented Aug 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 70%)

See analysis details on SonarCloud

@@ -223,7 +223,8 @@ public <T> CompletableFuture<T> get(Object key, Argument<T> requiredType, Suppli
Optional<T> deserialized = valueSerializer.deserialize(data, requiredType);
boolean hasValue = deserialized.isPresent();
if (expireAfterAccess != null && hasValue) {
return redisKeyAsyncCommands.expire(serializedKey, expireAfterAccess).thenApply(ignore -> deserialized.get());
final long expireAfterAccessInSeconds = expireAfterAccess / 1000;
return redisKeyAsyncCommands.expire(serializedKey, expireAfterAccessInSeconds).thenApply(ignore -> deserialized.get());
Copy link
Contributor

@Mike-Svendsen-IL Mike-Svendsen-IL Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of converting to milliseconds (which could lose precision), maybe just use pexpire? (https://redis.io/docs/latest/commands/pexpire/)

Update - or I guess you mention something about pexpire in the PR description, but it isn't clear to me why not to use it here instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed , using pexpire would solve the issue rather than converting to milliseconds, I've added tests that hit the methods .

@ChaimaaeROUAI ChaimaaeROUAI self-assigned this Sep 13, 2024
@CLAassistant
Copy link

CLAassistant commented Sep 13, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

sonarcloud bot commented Sep 13, 2024

@sdelamo sdelamo marked this pull request as ready for review September 18, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Redis Lettuce Expiration Set Incorrectly
4 participants