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

fix: change storage ttl time from seconds to milliseconds #2822

Merged

Conversation

luky116
Copy link
Collaborator

@luky116 luky116 commented Jul 23, 2024

fix #2821

1、将 floyd 存储的 date 字段的值从秒改为了 millseconds;
2、将 version 字段的值从秒改为了 micro-seconds;
3、floyd 中的 ctime 和 etime 字段,最高位的 bit,如果为1,表示毫秒单位,如果为0,表示秒级单位。因为之前存储的数据都是秒,这样能兼容历史版本的数据

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced time-to-live (TTL) functionality by introducing a precise PTTL (milliseconds) method for key timestamp retrieval.
    • Streamlined cache logic to directly access the database for PTTL operations, improving performance.
    • Added a new TTL method for clearer distinction in key expiration management.
    • Updated timestamp handling in various classes to support milliseconds, enhancing precision.
    • Improved API clarity by renaming time-related parameters to include "_millsec" in relevant methods.
  • Bug Fixes

    • Improved error handling for negative timestamps to ensure appropriate internal error messages.
  • Refactor

    • Implemented consistent time retrieval across various classes and methods using the new milliseconds approach.
  • Style

    • Renamed time-related member variables for clarity regarding their units in several command classes.
  • Tests

    • Enhanced precision of time management in unit tests by utilizing milliseconds for time calculations.

@luky116 luky116 changed the title change storage ttl time from seconds to milliseconds fix: change storage ttl time from seconds to milliseconds Jul 23, 2024
Copy link

coderabbitai bot commented Jul 23, 2024

Walkthrough

The changes enhance the time-to-live (TTL) command functionality by transitioning from a second-based approach to a more precise millisecond-based method with the introduction of the PTTL command. Key updates include refined cache management, updated time retrieval across components, and consistent handling of timestamps, all aimed at improving performance and clarity.

Changes

Files Change Summary
src/pika_kv.cc Updated PttlCmd to use PTTL, simplifying cache reads and improving error handling.
src/storage/src/storage.cc, src/storage/include/storage/storage.h Introduced a new PTTL method, renamed the previous TTL method to PTTL, and enhanced error handling in the newly defined TTL.
src/storage/src/redis_hashes.cc, src/storage/src/redis_strings.cc Standardized the method of obtaining the current time by replacing GetCurrentTime with NowMillis().
src/storage/tests/keys_test.cc Updated test cases to utilize NowMillis() for current time retrieval, enhancing test reliability and accuracy.
src/storage/include/storage/storage.h, src/storage/src/redis.h Renamed TTL parameters to clarify that they are specified in milliseconds, improving method signatures for clarity.

Assessment against linked issues

Objective Addressed Explanation
Save TTL with milliseconds instead of seconds (e.g., #2821)
Ensure commands return the correct time format for TTL
Address regression issues related to previous TTL handling

Poem

🐰 In a world where time takes flight,
Milliseconds shine, oh what a sight!
PTTL hops with grace and cheer,
No more waiting, the future's near!
With each tick, our code's a delight,
Time to live, everything feels right! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Jul 23, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a428088 and f5eaaf8.

Files selected for processing (18)
  • src/pika_kv.cc (2 hunks)
  • src/storage/include/storage/storage.h (1 hunks)
  • src/storage/src/base_filter.h (2 hunks)
  • src/storage/src/base_meta_value_format.h (1 hunks)
  • src/storage/src/base_value_format.h (3 hunks)
  • src/storage/src/lists_filter.h (1 hunks)
  • src/storage/src/lists_meta_value_format.h (2 hunks)
  • src/storage/src/redis_hashes.cc (3 hunks)
  • src/storage/src/redis_lists.cc (3 hunks)
  • src/storage/src/redis_sets.cc (3 hunks)
  • src/storage/src/redis_streams.cc (1 hunks)
  • src/storage/src/redis_strings.cc (4 hunks)
  • src/storage/src/redis_zsets.cc (3 hunks)
  • src/storage/src/storage.cc (4 hunks)
  • src/storage/src/strings_filter.h (1 hunks)
  • src/storage/src/zsets_filter.h (1 hunks)
  • src/storage/tests/keys_test.cc (1 hunks)
  • src/storage/tests/strings_test.cc (1 hunks)
Files skipped from review due to trivial changes (5)
  • src/storage/src/base_meta_value_format.h
  • src/storage/src/redis_hashes.cc
  • src/storage/src/redis_streams.cc
  • src/storage/src/redis_strings.cc
  • src/storage/tests/strings_test.cc
Additional comments not posted (25)
src/storage/src/strings_filter.h (1)

23-23: LGTM! Verify the usage of NowMicros across the codebase.

The change to use NowMicros for more precise time measurement is approved.

Ensure that NowMicros is used consistently across the codebase for time-related operations.

Verification successful

LGTM! Verify the usage of NowMicros across the codebase.

The change to use NowMicros for more precise time measurement is approved.

Ensure that NowMicros is used consistently across the codebase for time-related operations. The provided context shows consistent usage, but a thorough review across all instances is recommended.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `NowMicros` across the codebase.

# Test: Search for the usage of `NowMicros`. Expect: Consistent usage across the codebase.
rg --type cpp -A 5 'NowMicros'

Length of output: 38604

src/storage/src/base_value_format.h (2)

125-126: LGTM! Verify the usage of NowMicros across the codebase.

The change to use NowMicros for more precise timestamp calculation is approved.

Ensure that NowMicros is used consistently across the codebase for time-related operations.

Verification successful

Consistent Usage of NowMicros Verified

The usage of NowMicros across the codebase is consistent and correct, often converting microseconds to milliseconds where appropriate. The change in base_value_format.h aligns well with the rest of the codebase.

  • Verified consistent usage of NowMicros across various files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `NowMicros` across the codebase.

# Test: Search for the usage of `NowMicros`. Expect: Consistent usage across the codebase.
rg --type cpp -A 5 'NowMicros'

Length of output: 38604


55-56: LGTM! Verify the usage of NowMicros across the codebase.

The change to use NowMicros for more precise timestamp calculation is approved.

Ensure that NowMicros is used consistently across the codebase for time-related operations.

Verification successful

LGTM! The usage of NowMicros is consistent across the codebase.

The change to use NowMicros for more precise timestamp calculation is approved. The function is used consistently for time-related operations across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `NowMicros` across the codebase.

# Test: Search for the usage of `NowMicros`. Expect: Consistent usage across the codebase.
rg --type cpp -A 5 'NowMicros'

Length of output: 38604

src/storage/src/zsets_filter.h (1)

83-83: LGTM! Verify the usage of NowMicros across the codebase.

The change to use NowMicros for more precise time measurement is approved.

Ensure that NowMicros is used consistently across the codebase for time-related operations.

Verification successful

Verified: Consistent usage of NowMicros across the codebase.

The NowMicros function is used consistently across various files for obtaining the current time in microseconds, often divided by 1000 to convert to milliseconds. The change in zsets_filter.h aligns with this usage pattern.

  • src/pika_auxiliary_thread.cc
  • src/pika_client_conn.cc
  • src/pika_repl_client_conn.cc
  • src/pika_rm.cc
  • src/throttle.cc
  • src/rsync_client.cc
  • src/pika_statistic.cc
  • src/storage/src/base_value_format.h
  • src/storage/src/redis_hashes.cc
  • src/storage/src/base_filter.h
  • src/storage/src/strings_filter.h
  • src/storage/src/redis_lists.cc
  • src/storage/src/lists_filter.h
  • src/storage/src/base_meta_value_format.h
  • src/storage/src/redis_zsets.cc
  • src/storage/src/lists_meta_value_format.h
  • src/storage/src/redis.h
  • src/pika_repl_server_conn.cc
  • src/pika_server.cc
  • src/pika_repl_bgworker.cc
  • src/pika_db.cc
  • src/pika_consensus.cc
  • src/pika_command.cc
  • src/pika_cache_load_thread.cc
  • src/net/examples/thread_pool_test.cc
  • src/net/examples/performance/server.cc
  • tools/benchmark_client/benchmark_client.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `NowMicros` across the codebase.

# Test: Search for the usage of `NowMicros`. Expect: Consistent usage across the codebase.
rg --type cpp -A 5 'NowMicros'

Length of output: 38604

src/storage/src/lists_filter.h (1)

91-91: LGTM! The current time retrieval is now simplified and consistent.

The change updates the method of retrieving the current time to use milliseconds instead of seconds, which simplifies the code and ensures consistency.

src/storage/src/lists_meta_value_format.h (2)

54-54: LGTM! The current time retrieval is now simplified and consistent.

The change updates the method of retrieving the current time to use milliseconds instead of seconds, which simplifies the code and ensures consistency.


200-200: LGTM! The current time retrieval is now simplified and consistent.

The change updates the method of retrieving the current time to use milliseconds instead of seconds, which simplifies the code and ensures consistency.

src/storage/src/base_filter.h (2)

31-31: LGTM! The current time retrieval is now simplified and consistent.

The change updates the method of retrieving the current time to use milliseconds instead of seconds, which simplifies the code and ensures consistency.


182-182: LGTM! The current time retrieval is now simplified and consistent.

The change updates the method of retrieving the current time to use milliseconds instead of seconds, which simplifies the code and ensures consistency.

src/pika_kv.cc (2)

1445-1446: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ReadCache match the new implementation.

Verification successful

Verification Successful for PttlCmd::ReadCache

The ReadCache function in the PttlCmd class has been correctly updated to call DoThroughDB directly, as Redis cache does not support PTTL cache. This ensures consistency in PTTL handling.

However, it is recommended to verify other command classes to ensure they follow the expected pattern of cache usage.

  • GetCmd::ReadCache
  • MgetCmd::ReadCache
  • GetrangeCmd::ReadCache
  • StrlenCmd::ReadCache
  • ExistsCmd::ReadCache
  • TtlCmd::ReadCache
  • TypeCmd::ReadCache
  • ZCardCmd::ReadCache
  • ZRangeCmd::ReadCache
  • ZRevrangeCmd::ReadCache
  • ZRangebyscoreCmd::ReadCache
  • ZRevrangebyscoreCmd::ReadCache
  • ZCountCmd::ReadCache
  • ZRankCmd::ReadCache
  • ZRevrankCmd::ReadCache
  • ZScoreCmd::ReadCache
  • ZRangebylexCmd::ReadCache
  • ZRevrangebylexCmd::ReadCache
  • ZLexcountCmd::ReadCache
  • SCardCmd::ReadCache
  • SMembersCmd::ReadCache
  • SIsmemberCmd::ReadCache
  • SRandmemberCmd::ReadCache
  • HGetCmd::ReadCache
  • HGetallCmd::ReadCache
  • HExistsCmd::ReadCache
  • HKeysCmd::ReadCache
  • HLenCmd::ReadCache
  • HMgetCmd::ReadCache
  • HStrlenCmd::ReadCache
  • HValsCmd::ReadCache
  • LIndexCmd::ReadCache
  • LLenCmd::ReadCache
  • LRangeCmd::ReadCache
  • RPopLPushCmd::ReadCache
  • BitGetCmd::ReadCache
  • BitCountCmd::ReadCache
  • BitPosCmd::ReadCache
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ReadCache` match the new implementation.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type cpp -A 5 $'ReadCache'

Length of output: 44694


Line range hint 1436-1440:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PTTL match the new implementation.

Verification successful

The function PTTL is used in the following files:

  • src/pika_kv.cc
  • src/storage/include/storage/storage.h
  • src/storage/src/storage.cc

The implementation and usage of PTTL in src/storage/src/storage.cc need to be reviewed to ensure they align with the new changes.


Verification successful: The PTTL function implementation aligns with the new changes to use milliseconds for TTL values. The function is correctly implemented and handles errors appropriately.

  • src/storage/src/storage.cc: Verified implementation of PTTL.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PTTL` match the new implementation.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type cpp -A 5 $'PTTL'

Length of output: 2142


Script:

#!/bin/bash
# Description: Review the implementation of the `PTTL` function in `src/storage/src/storage.cc`.

# Search for the implementation of the `PTTL` function in the file.
rg --type cpp -A 10 $'int64_t Storage::PTTL(const Slice& key)'

Length of output: 63


Script:

#!/bin/bash
# Description: Re-verify the implementation of the `PTTL` function in the entire codebase.

# Search for the implementation of the `PTTL` function in the entire codebase.
rg --type cpp -A 10 $'int64_t PTTL(const Slice& key)'

Length of output: 54


Script:

#!/bin/bash
# Description: Re-verify the implementation of the `PTTL` function in the entire codebase.

# Search for the implementation of the `PTTL` function in the entire codebase without specifying the return type.
rg --type cpp -A 10 $'PTTL(const Slice& key)'

Length of output: 46


Script:

#!/bin/bash
# Description: Re-verify the implementation of the `PTTL` function in the entire codebase.

# Search for all function definitions in the codebase and filter for `PTTL`.
rg --type cpp --pcre2 -A 10 '\bPTTL\b' --glob '*.*'

Length of output: 5588

src/storage/include/storage/storage.h (2)

1037-1037: Typographical correction approved.

The correction from "Reutrns" to "Returns" is accurate and does not affect the logic or functionality of the code.


1030-1035: Verify the implementation of the PTTL method.

The method signature and comments look correct. Ensure that the implementation of this method in the corresponding .cpp file aligns with the described behavior:

  • Returns -3 for operation exceptions.
  • Returns -2 if the key does not exist.
  • Returns -1 if the key exists but has no associated expiration.
  • Returns a positive value representing the TTL in milliseconds if the key is valid.
src/storage/src/redis_lists.cc (3)

33-33: Efficient time retrieval.

The change to use rocksdb::Env::Default()->NowMicros() / 1000 for retrieving the current time in milliseconds is more efficient and simplifies the logic.


505-505: Efficient time retrieval.

The change to use rocksdb::Env::Default()->NowMicros() / 1000 for retrieving the current time in milliseconds is more efficient and simplifies the logic.


1288-1288: Efficient time retrieval.

The change to use rocksdb::Env::Default()->NowMicros() / 1000 for retrieving the current time in milliseconds is more efficient and simplifies the logic.

src/storage/src/storage.cc (2)

Line range hint 1471-1481:
Verify the function usage in the codebase.

The PTTL function has been renamed from TTL and modified to return the timestamp directly in milliseconds. Ensure that all function calls to PTTL match the new behavior.

Verification successful

Verify the function usage in the codebase.

The function PTTL has been correctly updated and used in the codebase. The new behavior is consistent, and the function calls handle the returned timestamp appropriately.

  • src/pika_kv.cc: The function call to PTTL checks for the -3 error code and appends the timestamp to the response.
  • src/storage/include/storage/storage.h: The function declaration matches the new behavior.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PTTL` match the new behavior.

# Test: Search for the function usage. Expect: Only occurances of the new behavior.
rg --type cpp -A 5 $'PTTL'

Length of output: 2142


1483-1493: Verify the function usage in the codebase.

The TTL function has been introduced to handle TTL values in seconds, converting milliseconds to seconds. Ensure that all function calls to TTL match the new behavior.

src/storage/src/redis_sets.cc (3)

37-37: LGTM!

The change to retrieve the current time in milliseconds aligns with the objective of transitioning to millisecond precision.


777-777: LGTM!

The change to retrieve the current time in milliseconds aligns with the objective of transitioning to millisecond precision.


1597-1597: LGTM!

The change to retrieve the current time in milliseconds aligns with the objective of transitioning to millisecond precision.

src/storage/src/redis_zsets.cc (3)

39-39: Improved readability and conciseness.

The change to retrieve the current time in milliseconds directly improves readability and reduces boilerplate code.


570-570: Improved readability and conciseness.

The change to retrieve the current time in milliseconds directly improves readability and reduces boilerplate code.


1946-1946: Improved readability and conciseness.

The change to retrieve the current time in milliseconds directly improves readability and reduces boilerplate code.

src/storage/tests/keys_test.cc (1)

5116-5118: LGTM! Simplified time retrieval.

The change simplifies the code by directly retrieving the current time in microseconds and converting it to milliseconds. This reduces the number of function calls and potentially improves performance. The functionality remains unchanged.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f5eaaf8 and 8f957fc.

Files selected for processing (1)
  • src/pika_kv.cc (2 hunks)
Additional comments not posted (2)
src/pika_kv.cc (2)

1445-1446: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ReadCache match the new usage.


Line range hint 1436-1440:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PTTL match the new usage.

Verification successful

Verification successful: All function calls to PTTL match the new usage.

  • The PttlCmd::Do() method correctly uses PTTL to retrieve the TTL in milliseconds.
  • The PttlCmd::ReadCache() method does not interact with the cache and directly reads from the database, ensuring no issues with cache handling.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PTTL` match the new usage.

# Test: Search for the function usage. Expect: Only occurrences of the new usage.
rg --type cpp -A 5 $'PTTL'

Length of output: 2142


Script:

#!/bin/bash
# Description: Verify the implementation of `ReadCache()` method in `src/pika_kv.cc`.

# Test: Search for the `ReadCache` method definition in the file.
rg --type cpp -A 10 $'ReadCache' src/pika_kv.cc

Length of output: 2193

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8f957fc and abde555.

Files selected for processing (2)
  • src/storage/src/base_meta_value_format.h (2 hunks)
  • src/storage/src/lists_meta_value_format.h (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/storage/src/base_meta_value_format.h
  • src/storage/src/lists_meta_value_format.h

src/storage/src/lists_meta_value_format.h Outdated Show resolved Hide resolved
src/storage/src/lists_meta_value_format.h Outdated Show resolved Hide resolved
src/storage/src/storage.cc Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
src/storage/src/storage.cc (1)

1471-1475: Document the error code -3.

For better readability and maintainability, document the meaning of the error code -3 returned by this method.

// Returns -3 if the key is not found or an error occurs.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between abde555 and 7169ecd.

Files selected for processing (1)
  • src/storage/src/storage.cc (3 hunks)
Additional comments not posted (2)
src/storage/src/storage.cc (2)

1481-1489: LGTM!

The TTL method is correctly implemented and handles the conversion from milliseconds to seconds properly.


1784-1786: LGTM!

The SetSmallCompactionThreshold method is correctly implemented.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7169ecd and 4e68b93.

Files selected for processing (3)
  • src/storage/src/base_meta_value_format.h (2 hunks)
  • src/storage/src/lists_meta_value_format.h (2 hunks)
  • src/storage/src/storage.cc (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • src/storage/src/base_meta_value_format.h
  • src/storage/src/lists_meta_value_format.h
  • src/storage/src/storage.cc

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4e68b93 and 00a9ae4.

Files selected for processing (1)
  • .github/workflows/pika.yml (2 hunks)
Additional comments not posted (2)
.github/workflows/pika.yml (2)

57-57: Enhance test output verbosity.

Adding the --verbose flag to the ctest command will provide more detailed output during the testing process, which can be beneficial for debugging and understanding test results.


114-114: Enhance test output verbosity.

Adding the --verbose flag to the ctest command will provide more detailed output during the testing process, which can be beneficial for debugging and understanding test results.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 00a9ae4 and e55311c.

Files selected for processing (1)
  • src/storage/tests/strings_test.cc (4 hunks)
Additional comments not posted (6)
src/storage/tests/strings_test.cc (6)

948-949: Ensure accurate time conversion.

The unix_time calculation now uses rocksdb::Env::Default()->NowMicros() / 1000 to convert microseconds to milliseconds. This change ensures higher precision in time handling.


959-962: Ensure accurate time conversion.

The unix_time calculation now uses rocksdb::Env::Default()->NowMicros() / 1000 to convert microseconds to milliseconds. This change ensures higher precision in time handling.


972-973: Ensure accurate time conversion.

The unix_time calculation now uses rocksdb::Env::Default()->NowMicros() / 1000 to convert microseconds to milliseconds. This change ensures higher precision in time handling.


981-984: Ensure accurate time conversion.

The unix_time calculation now uses rocksdb::Env::Default()->NowMicros() / 1000 to convert microseconds to milliseconds. This change ensures higher precision in time handling.


992-992: Ensure accurate time conversion.

The unix_time calculation now uses rocksdb::Env::Default()->NowMicros() / 1000 to convert microseconds to milliseconds. This change ensures higher precision in time handling.


1001-1001: Ensure accurate time conversion.

The unix_time calculation now uses rocksdb::Env::Default()->NowMicros() / 1000 to convert microseconds to milliseconds. This change ensures higher precision in time handling.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e55311c and b4450a9.

Files selected for processing (1)
  • src/storage/src/redis_hashes.cc (4 hunks)
Additional comments not posted (4)
src/storage/src/redis_hashes.cc (4)

34-34: LGTM! Improved time retrieval method.

The change to use rocksdb::Env::Default()->NowMicros() / 1000 for retrieving the current time improves precision and performance.


255-255: LGTM! Improved time retrieval method.

The change to use rocksdb::Env::Default()->NowMicros() / 1000 for retrieving the current time improves precision and performance.


1346-1346: LGTM! Improved time retrieval method.

The change to use rocksdb::Env::Default()->NowMicros() / 1000 for retrieving the current time improves precision and performance.


1122-1122: LGTM! Improved type safety for version handling.

The change to use uint64_t for start_key_version improves type safety and allows for a broader range of values without overflow risk.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b4450a9 and 3bcfe99.

Files selected for processing (4)
  • src/pstd/include/env.h (1 hunks)
  • src/pstd/src/env.cc (1 hunks)
  • src/storage/tests/keys_test.cc (1 hunks)
  • src/storage/tests/strings_test.cc (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/storage/tests/strings_test.cc
Additional comments not posted (3)
src/pstd/include/env.h (1)

66-67: LGTM! The function declaration is clear and consistent.

The NowMillis function declaration is correct and aligns well with the existing NowMicros function.

src/pstd/src/env.cc (1)

225-229: LGTM! The function implementation is correct and efficient.

The NowMillis function correctly captures the current time and converts it to milliseconds using std::chrono.

src/storage/tests/keys_test.cc (1)

5116-5119: Simplified time retrieval process aligns with PR objectives.

The change to use pstd::NowMillis() for getting the current time in milliseconds simplifies the code and aligns with the objective of handling TTL in milliseconds. The functional outcome remains consistent.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3bcfe99 and 6c954ea.

Files selected for processing (12)
  • src/storage/src/base_filter.h (2 hunks)
  • src/storage/src/base_meta_value_format.h (2 hunks)
  • src/storage/src/base_value_format.h (4 hunks)
  • src/storage/src/lists_filter.h (1 hunks)
  • src/storage/src/lists_meta_value_format.h (2 hunks)
  • src/storage/src/redis_hashes.cc (4 hunks)
  • src/storage/src/redis_lists.cc (3 hunks)
  • src/storage/src/redis_sets.cc (4 hunks)
  • src/storage/src/redis_strings.cc (4 hunks)
  • src/storage/src/redis_zsets.cc (3 hunks)
  • src/storage/src/strings_filter.h (1 hunks)
  • src/storage/src/zsets_filter.h (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/storage/src/zsets_filter.h
Files skipped from review as they are similar to previous changes (1)
  • src/storage/src/redis_hashes.cc
Additional comments not posted (25)
src/storage/src/strings_filter.h (1)

23-23: LGTM! Ensure consistency with the rest of the codebase.

The change to use pstd::NowMillis() for obtaining the current time in milliseconds is correct. Ensure this method is consistently used throughout the codebase for time retrieval.

src/storage/src/base_value_format.h (4)

44-44: LGTM!

The change to use pstd::NowMillis() for initializing ctime_ in the constructor is correct.


55-56: LGTM!

The change to use pstd::NowMillis() and convert ttl to milliseconds in the SetRelativeTimestamp method is correct.


125-126: LGTM!

The change to use pstd::NowMillis() and convert ttl to milliseconds in the SetRelativeTimestamp method is correct.


136-136: LGTM!

The change to use pstd::NowMillis() for obtaining the current time in milliseconds in the IsStale method is correct.

src/storage/src/lists_filter.h (1)

91-91: LGTM! Ensure consistency with the rest of the codebase.

The change to use pstd::NowMillis() for obtaining the current time in milliseconds is correct. Ensure this method is consistently used throughout the codebase for time retrieval.

src/storage/src/base_meta_value_format.h (2)

Line range hint 49-53:
LGTM!

The UpdateVersion method now uses pstd::NowMillis() to retrieve the current time in milliseconds, which aligns with the PR objectives.


Line range hint 174-180:
LGTM!

The UpdateVersion method now uses pstd::NowMillis() to retrieve the current time in milliseconds, which aligns with the PR objectives.

src/storage/src/lists_meta_value_format.h (2)

Line range hint 54-60:
LGTM!

The UpdateVersion method now uses pstd::NowMillis() to retrieve the current time in milliseconds, which aligns with the PR objectives.


Line range hint 200-206:
LGTM!

The UpdateVersion method now uses pstd::NowMillis() to retrieve the current time in milliseconds, which aligns with the PR objectives.

src/storage/src/base_filter.h (2)

31-33: LGTM!

The Filter method now uses pstd::NowMillis() to retrieve the current time in milliseconds, which aligns with the PR objectives.


182-184: LGTM!

The Filter method now uses pstd::NowMillis() to retrieve the current time in milliseconds, which aligns with the PR objectives.

src/storage/src/redis_lists.cc (3)

33-33: LGTM! The change improves performance and clarity.

Replacing rocksdb::Env::Default()->GetCurrentTime(&curtime) with curtime = pstd::NowMillis() simplifies the code and may improve performance by reducing overhead.


505-505: LGTM! The change improves performance and clarity.

Replacing rocksdb::Env::Default()->GetCurrentTime(&curtime) with curtime = pstd::NowMillis() simplifies the code and may improve performance by reducing overhead.


1288-1288: LGTM! The change improves performance and clarity.

Replacing rocksdb::Env::Default()->GetCurrentTime(&curtime) with curtime = pstd::NowMillis() simplifies the code and may improve performance by reducing overhead.

src/storage/src/redis_strings.cc (4)

36-36: LGTM!

The change to use pstd::NowMillis() improves readability and potentially performance.


380-380: LGTM!

The change to use pstd::NowMillis() improves readability and potentially performance.


556-556: LGTM!

The change to use pstd::NowMillis() improves readability and potentially performance.


1469-1469: LGTM!

The change to use pstd::NowMillis() improves readability and potentially performance.

src/storage/src/redis_sets.cc (3)

37-37: LGTM! The change aligns with the objective of handling TTL values in milliseconds.

The replacement of rocksdb::Env::Default()->GetCurrentTime(&curtime) with curtime = pstd::NowMillis() is appropriate and aligns with the PR objectives.


777-777: LGTM! The change aligns with the objective of handling TTL values in milliseconds.

The replacement of rocksdb::Env::Default()->GetCurrentTime(&curtime) with curtime = pstd::NowMillis() is appropriate and aligns with the PR objectives.


1595-1595: LGTM! The change aligns with the objective of handling TTL values in milliseconds.

The replacement of rocksdb::Env::Default()->GetCurrentTime(&curtime) with curtime = pstd::NowMillis() is appropriate and aligns with the PR objectives.

src/storage/src/redis_zsets.cc (3)

39-39: LGTM! Simplified time retrieval.

The change simplifies the code by directly obtaining the current time in milliseconds using pstd::NowMillis(). This aligns with the PR objective of handling TTL values in milliseconds.


570-572: LGTM! Simplified time retrieval.

The change simplifies the code by directly obtaining the current time in milliseconds using pstd::NowMillis(). This aligns with the PR objective of handling TTL values in milliseconds.


1946-1948: LGTM! Simplified time retrieval.

The change simplifies the code by directly obtaining the current time in milliseconds using pstd::NowMillis(). This aligns with the PR objective of handling TTL values in milliseconds.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4237b51 and c465f67.

Files selected for processing (16)
  • src/pika_admin.cc (2 hunks)
  • src/pika_bit.cc (1 hunks)
  • src/pika_conf.cc (2 hunks)
  • src/pika_geo.cc (1 hunks)
  • src/pika_kv.cc (6 hunks)
  • src/pika_list.cc (1 hunks)
  • src/pika_server.cc (5 hunks)
  • src/pika_zset.cc (5 hunks)
  • src/storage/src/base_meta_value_format.h (5 hunks)
  • src/storage/src/lists_meta_value_format.h (5 hunks)
  • src/storage/src/redis_hashes.cc (10 hunks)
  • src/storage/src/redis_sets.cc (9 hunks)
  • src/storage/src/redis_strings.cc (5 hunks)
  • src/storage/src/redis_zsets.cc (11 hunks)
  • src/storage/src/storage.cc (6 hunks)
  • src/storage/src/strings_value_format.h (4 hunks)
Files skipped from review due to trivial changes (7)
  • src/pika_admin.cc
  • src/pika_bit.cc
  • src/pika_conf.cc
  • src/pika_geo.cc
  • src/pika_list.cc
  • src/pika_server.cc
  • src/pika_zset.cc
Files skipped from review as they are similar to previous changes (8)
  • src/storage/src/base_meta_value_format.h
  • src/storage/src/lists_meta_value_format.h
  • src/storage/src/redis_hashes.cc
  • src/storage/src/redis_sets.cc
  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_zsets.cc
  • src/storage/src/storage.cc
  • src/storage/src/strings_value_format.h
Additional comments not posted (6)
src/pika_kv.cc (6)

494-494: LGTM!

The change to directly call the Do method in AppendCmd::DoThroughDB is straightforward and maintains the existing logic.


1296-1296: LGTM!

The change to directly call the Do method in PexpireCmd::DoThroughDB is straightforward and maintains the existing logic.


532-532: LGTM!

The change to handle cases where cache_miss_keys_ is empty in MgetCmd::Do is logical and ensures proper functionality.


947-947: LGTM!

The change to iterate over kvs_ to generate binlog entries in MsetCmd::DoBinlog is logical and ensures proper functionality.


1436-1436: LGTM!

The change to use the PTTL method to retrieve the time-to-live value in PttlCmd::Do is logical and ensures proper functionality.


1445-1446: LGTM!

The change to directly call DoThroughDB to read from the database in PttlCmd::ReadCache is logical and ensures proper functionality.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
src/storage/src/redis.h (1)

188-188: Update required: Instances of Expire using the old signature

There are still instances of the Expire method using the old signature with ttl instead of ttl_millsec. Please update the following occurrences to use the new signature with ttl_millsec:

  • src/pika_cache.cc

    • Line 1: Status PikaCache::Expire(std::string& key, int64_t ttl)
    • Line 2: return caches_[cache_index]->Expire(key, ttl)
    • Additional lines: Multiple occurrences within the file
  • src/cache/include/cache.h

    • Line 1: Status Expire(std::string& key, int64_t ttl)
    • Line 2: Status Expireat(std::string& key, int64_t ttl)
  • src/cache/src/cache.cc

    • Line 1: Status RedisCache::Expire(std::string& key, int64_t ttl)
    • Line 2: Status RedisCache::Expireat(std::string& key, int64_t ttl)

Please ensure that all instances are updated accordingly.

Analysis chain

LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to Expire are updated accordingly.


Verify all instances of Expire have been updated to use ttl_millsec.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. However, there are still some instances in the codebase that might be using the old signature. Let's verify and ensure that all calls to Expire are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Expire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'Expire'

Length of output: 53310


Script:

#!/bin/bash
# Description: Verify all function calls to `Expire` match the new signature with `ttl_millsec`.

# Test: Search for the function usage with the old signature. Expect: No occurrences of the old signature.
rg --type cpp -A 5 $'Expire(.*ttl[^_])'

Length of output: 3304

src/storage/include/storage/storage.h (1)

963-963: Update all instances of Expire to use the new signature

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. However, there are still instances in the codebase where the old signature is being used. Ensure that all calls to Expire are updated accordingly.

  • Files to update:
    • src/storage/tests/strings_test.cc
    • src/storage/tests/keys_test.cc
    • src/storage/tests/sets_test.cc
    • src/storage/tests/zsets_test.cc
    • src/storage/tests/lists_test.cc
    • src/storage/tests/hashes_test.cc
    • src/storage/examples/strings_example.cc
    • src/storage/examples/hashes_example.cc
Analysis chain

LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to Expire are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Expire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'Expire'

Length of output: 53310

src/pika_cache.cc (1)

129-132: Update the parameter name in the following files to ensure consistency:

  • src/cache/src/cache.cc: Change ttl to milliseconds in the Expireat method.
  • include/pika_cache.h: Change ttl to milliseconds in the Expireat method declaration.
Analysis chain

LGTM! But verify the function usage in the codebase.

The parameter name change from ttl to milliseconds improves clarity and aligns with the PR objectives.

However, ensure that all function calls to Expireat match the new parameter name.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Expireat` match the new parameter name.

# Test: Search for the function usage. Expect: Only occurrences of the new parameter name.
rg --type cpp -A 5 $'Expireat'

Length of output: 14462

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c465f67 and 30a71a6.

Files selected for processing (12)
  • include/pika_kv.h (4 hunks)
  • src/pika_cache.cc (1 hunks)
  • src/pika_kv.cc (14 hunks)
  • src/storage/include/storage/storage.h (3 hunks)
  • src/storage/src/base_value_format.h (4 hunks)
  • src/storage/src/redis.h (3 hunks)
  • src/storage/src/redis_hashes.cc (14 hunks)
  • src/storage/src/redis_lists.cc (7 hunks)
  • src/storage/src/redis_sets.cc (13 hunks)
  • src/storage/src/redis_strings.cc (9 hunks)
  • src/storage/src/redis_zsets.cc (15 hunks)
  • src/storage/src/storage.cc (8 hunks)
Files skipped from review due to trivial changes (2)
  • include/pika_kv.h
  • src/storage/src/redis_zsets.cc
Files skipped from review as they are similar to previous changes (6)
  • src/pika_kv.cc
  • src/storage/src/base_value_format.h
  • src/storage/src/redis_hashes.cc
  • src/storage/src/redis_sets.cc
  • src/storage/src/redis_strings.cc
  • src/storage/src/storage.cc
Additional comments not posted (20)
src/storage/src/redis.h (11)

120-120: LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to StringsExpire are updated accordingly.

Verification successful

Verified: Method usage is consistent with the new signature.

The StringsExpire method has been updated to use ttl_millsec, and all instances in the codebase reflect this change correctly.

  • src/storage/src/redis_strings.cc: Method definition and usage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `StringsExpire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'StringsExpire'

Length of output: 3017


121-121: LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to HashesExpire are updated accordingly.

Verification successful

The method usage in the codebase is consistent with the new signature.

The change to use ttl_millsec instead of ttl has been applied correctly in all instances of HashesExpire in the codebase.

  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_hashes.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `HashesExpire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'HashesExpire'

Length of output: 3208


122-122: LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to ListsExpire are updated accordingly.

Verification successful

Verification Complete: All usages of ListsExpire have been updated to use ttl_millsec.

The method signature change to use ttl_millsec instead of ttl is consistent across the codebase.

  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_lists.cc
  • src/storage/src/redis.h
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ListsExpire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ListsExpire'

Length of output: 3035


124-124: LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to SetsExpire are updated accordingly.

Verification successful

Verified: The method usage is consistent with the updated signature.

The change to use ttl_millsec instead of ttl has been correctly applied to all instances of SetsExpire in the codebase.

  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_sets.cc
  • src/storage/src/redis.h
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetsExpire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'SetsExpire'

Length of output: 3097


123-123: LGTM! But verify the method usage in the codebase.

The change to use ttl_millsec instead of ttl is clear and improves the API's clarity. Ensure that all calls to ZsetsExpire are updated accordingly.

Verification successful

LGTM! The method usage is consistent with the new signature.

The change to use ttl_millsec instead of ttl has been properly propagated throughout the codebase.

  • src/storage/src/redis_strings.cc: The method ZsetsExpire is called with the new signature.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsExpire` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ZsetsExpire'

Length of output: 3088


133-133: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to StringsExpireat are updated accordingly.


134-134: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to HashesExpireat are updated accordingly.

Verification successful

Verified: The method HashesExpireat has been updated to use the new signature consistently across the codebase.

  • src/storage/src/redis_strings.cc: Calls to HashesExpireat use timestamp_millsec.
  • src/storage/src/redis_hashes.cc: Implementation of HashesExpireat uses timestamp_millsec.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `HashesExpireat` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'HashesExpireat'

Length of output: 1655


136-136: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to SetsExpireat are updated accordingly.

Verification successful

Verification successful.

The method SetsExpireat has been correctly updated to use timestamp_millsec instead of timestamp across the codebase. The new signature is applied consistently in both the method definition and its usage.

  • src/storage/src/redis.h
  • src/storage/src/redis_sets.cc
  • src/storage/src/redis_strings.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetsExpireat` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'SetsExpireat'

Length of output: 1602


189-189: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to Expireat are updated accordingly.


135-135: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to ListsExpireat are updated accordingly.

Verification successful

Verification Successful: Method usage is consistent.

The ListsExpireat method has been updated to use timestamp_millsec instead of timestamp, and all occurrences in the codebase reflect this change. No instances of the old signature were found.

  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_lists.cc
  • src/storage/src/redis.h
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ListsExpireat` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ListsExpireat'

Length of output: 1562


Script:

#!/bin/bash
# Description: Verify no old function calls to `ListsExpireat` with the previous signature exist.

# Test: Search for the old function usage. Expect: No occurrences of the old signature.
rg --type cpp -A 5 $'ListsExpireat(.*timestamp'

Length of output: 138


Script:

#!/bin/bash
# Description: Verify no old function calls to `ListsExpireat` with the previous signature exist.

# Test: Search for the old function usage. Expect: No occurrences of the old signature.
rg --type cpp -A 5 $'ListsExpireat\(.*timestamp'

Length of output: 1577


137-137: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to ZsetsExpireat are updated accordingly.

Verification successful

Verification Complete: No issues found.

The method ZsetsExpireat has been updated to use timestamp_millsec consistently throughout the codebase. No instances of the old method signature were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsExpireat` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ZsetsExpireat'

Length of output: 1577


Script:

#!/bin/bash
# Description: Verify there are no remaining instances of the old method signature `ZsetsExpireat` with `timestamp`.

# Test: Search for the old function signature. Expect: No occurrences of the old signature.
rg --type cpp -A 5 $'ZsetsExpireat(const Slice& key, int64_t timestamp'

Length of output: 186


Script:

#!/bin/bash
# Description: Verify there are no remaining instances of the old method signature `ZsetsExpireat` with `timestamp`.

# Test: Search for the old function signature. Expect: No occurrences of the old signature.
rg --type cpp -A 5 'ZsetsExpireat\(const Slice& key, int64_t timestamp'

Length of output: 1093

src/storage/include/storage/storage.h (2)

1035-1035: LGTM! But verify the method usage in the codebase.

The addition of the PTTL method is a valuable enhancement for retrieving TTL in milliseconds. Ensure that the method is used correctly in the codebase.

Verification successful

Verify the usage of the PTTL method in pika_kv.cc.

The PTTL method is defined and implemented correctly. However, to ensure its proper usage, review the context around its usage in pika_kv.cc.


The usage of the PTTL method is correct.

The PTTL method is correctly used in pika_kv.cc to retrieve the TTL of a key and handle potential internal errors appropriately.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `PTTL` method in the codebase.

# Test: Search for the method usage. Expect: Correct usage of the new method.
rg --type cpp -A 5 $'PTTL'

Length of output: 2142


Script:

#!/bin/bash
# Description: Verify the context around the usage of the `PTTL` method in `pika_kv.cc`.

# Test: Search for the method usage in `pika_kv.cc`. Expect: Correct usage of the new method.
rg --type cpp -A 10 $'PTTL' src/pika_kv.cc

Length of output: 340


1013-1013: LGTM! But verify the method usage in the codebase.

The change to use timestamp_millsec instead of timestamp is clear and improves the API's clarity. Ensure that all calls to Expireat are updated accordingly.

Verification successful

Verify remaining instances of the old Expireat signature.

The output indicates that most instances of Expireat have been updated to use timestamp_millsec. However, a few instances might still be using the old signature. Please ensure that all occurrences have been updated.


All instances of Expireat have been updated to the new signature.

The search did not find any remaining instances of the old Expireat signature, confirming that all occurrences have been updated to use timestamp_millsec.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Expireat` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'Expireat'

Length of output: 14462


Script:

#!/bin/bash
# Description: Verify if there are any remaining instances of the old `Expireat` signature.

# Test: Search for the old function signature. Expect: No occurrences of the old signature.
rg --type cpp -A 5 $'Expireat(std::string& key, int64_t ttl)'

Length of output: 62

src/storage/src/redis_lists.cc (7)

33-33: LGTM!

The change to retrieve the current time in milliseconds using pstd::NowMillis() is appropriate and improves clarity.


505-505: LGTM!

The change to retrieve the current time in milliseconds using pstd::NowMillis() is appropriate and improves clarity.


1098-1098: LGTM!

The change to use ttl_millsec instead of ttl aligns with the PR objectives and ensures TTL is handled in milliseconds.


1127-1128: LGTM!

The method correctly updates the TTL in milliseconds.


1175-1175: LGTM!

The change to use timestamp_millsec instead of timestamp aligns with the PR objectives and ensures expiration time is handled in milliseconds.


1203-1204: LGTM!

The method correctly updates the expiration time in milliseconds.


1288-1288: LGTM!

The change to retrieve the current time in milliseconds using pstd::NowMillis() is appropriate and improves clarity.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 30a71a6 and 18199be.

Files selected for processing (1)
  • src/storage/tests/strings_test.cc (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/storage/tests/strings_test.cc

@@ -643,10 +643,9 @@ class PexpireatCmd : public Cmd {

private:
std::string key_;
int64_t time_stamp_ms_ = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

setex, psetex这两个命令也需要处理下。建议按照pika_command.h里的命令逐个梳理下,一个是调用的storage接口传的时间单位是否一致,另一个命令写binlog的时候传的ttl单位是否一致。

Copy link
Collaborator Author

@luky116 luky116 Aug 6, 2024

Choose a reason for hiding this comment

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

总结了下,有如下这些命令会影响,都处理了。其中有一些命令的 binlog 或是 cache 会有精度损失,这里新建了一个 issue,另做处理:#2847

image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 18199be and 9e53030.

Files selected for processing (16)
  • include/pika_cache.h (1 hunks)
  • include/pika_kv.h (10 hunks)
  • src/pika_cache.cc (1 hunks)
  • src/pika_cache_load_thread.cc (1 hunks)
  • src/pika_kv.cc (32 hunks)
  • src/storage/include/storage/storage.h (15 hunks)
  • src/storage/src/base_value_format.h (4 hunks)
  • src/storage/src/redis.h (7 hunks)
  • src/storage/src/redis_hashes.cc (16 hunks)
  • src/storage/src/redis_lists.cc (9 hunks)
  • src/storage/src/redis_sets.cc (15 hunks)
  • src/storage/src/redis_strings.cc (22 hunks)
  • src/storage/src/redis_zsets.cc (17 hunks)
  • src/storage/src/storage.cc (16 hunks)
  • src/storage/tests/lists_filter_test.cc (2 hunks)
  • src/storage/tests/strings_filter_test.cc (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/storage/src/redis_zsets.cc
Files skipped from review as they are similar to previous changes (9)
  • include/pika_kv.h
  • src/pika_cache.cc
  • src/storage/include/storage/storage.h
  • src/storage/src/base_value_format.h
  • src/storage/src/redis_hashes.cc
  • src/storage/src/redis_lists.cc
  • src/storage/src/redis_sets.cc
  • src/storage/src/redis_strings.cc
  • src/storage/src/storage.cc
Additional comments not posted (29)
src/storage/tests/strings_filter_test.cc (1)

24-24: LGTM!

The method SetRelativeTimeByMillsec correctly reflects the shift to handling TTL in milliseconds.

src/pika_cache_load_thread.cc (1)

118-124: LGTM!

The method LoadSet correctly handles TTL in milliseconds and converts it to seconds when writing to the cache.

src/storage/tests/lists_filter_test.cc (2)

105-105: LGTM!

The method SetRelativeTimeByMillsec correctly reflects the shift to handling TTL in milliseconds.


122-122: LGTM!

The method SetRelativeTimeByMillsec correctly reflects the shift to handling TTL in milliseconds.

include/pika_cache.h (1)

70-70: Clarification of parameter name.

The parameter name change from ttl to ttl_sec improves clarity by explicitly indicating that the parameter represents a time value in seconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.

src/storage/src/redis.h (13)

120-124: Clarification of parameter names to milliseconds.

The parameter name changes to ttl_millsec improve clarity by explicitly indicating that the parameters represent time values in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


133-137: Clarification of parameter names to milliseconds for expiration at a specific timestamp.

The parameter name changes to timestamp_millsec improve clarity by explicitly indicating that the parameters represent time values in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


145-149: Clarification of parameter names to milliseconds for TTL methods.

The parameter name changes to ttl_millsec improve clarity by explicitly indicating that the parameters represent time values in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


159-160: Clarification of parameter names to milliseconds for GetWithTTL methods.

The parameter name changes to ttl_millsec improve clarity by explicitly indicating that the parameters represent time values in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


164-164: Clarification of parameter names to milliseconds for GetrangeWithValue method.

The parameter name change to ttl_millsec improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


172-176: Clarification of parameter names to milliseconds for Set methods.

The parameter name changes to ttl_millsec improve clarity by explicitly indicating that the parameters represent time values in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


184-184: Clarification of parameter name to milliseconds for PKSetexAt method.

The parameter name change to time_stamp_millsec_ improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


188-189: Clarification of parameter names to milliseconds for Expire methods.

The parameter name changes to ttl_millsec and timestamp_millsec improve clarity by explicitly indicating that the parameters represent time values in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


191-191: Clarification of parameter name to milliseconds for TTL method.

The parameter name change to ttl_millsec improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


201-201: Clarification of parameter name to milliseconds for HGetallWithTTL method.

The parameter name change to ttl_millsec improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


258-258: Clarification of parameter name to milliseconds for SMembersWithTTL method.

The parameter name change to ttl_millsec improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


279-279: Clarification of parameter name to milliseconds for LRangeWithTTL method.

The parameter name change to ttl_millsec improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.


294-294: Clarification of parameter name to milliseconds for ZRangeWithTTL method.

The parameter name change to ttl_millsec improves clarity by explicitly indicating that the parameter represents a time value in milliseconds. This enhances code readability and reduces potential confusion regarding the unit of measurement.

src/pika_kv.cc (11)

25-25: Initialize ttl_millsec to 0.

The initialization of ttl_millsec to 0 is correct and ensures that TTL is handled in milliseconds.


54-55: Convert TTL from seconds to milliseconds.

The conversion of TTL from seconds to milliseconds using ttl_millsec *= 1000 is correct and ensures consistency in TTL handling.


70-79: Update storage calls to use ttl_millsec.

The updates to the storage calls to use ttl_millsec ensure that TTL is handled in milliseconds.


114-114: Update cache calls to use ttl_millsec / 1000.

The updates to the cache calls to use ttl_millsec / 1000 ensure that TTL is handled correctly in seconds.


161-161: Update storage call to use GetWithTTL.

The update to the storage call to use GetWithTTL ensures that TTL is retrieved in milliseconds.


191-191: Update cache call to use ttl_millsec_ / 1000.

The update to the cache call to use ttl_millsec_ / 1000 ensures that TTL is handled correctly in seconds.


496-496: Add AppendCmd::DoThroughDB method.

The addition of the AppendCmd::DoThroughDB method follows the pattern used in other command methods.


534-534: Update storage call to use MGetWithTTL.

The update to the storage call to use MGetWithTTL ensures that TTL is retrieved in milliseconds.


606-607: Update cache call to use ttl_millsec / 1000.

The update to the cache call to use ttl_millsec / 1000 ensures that TTL is handled correctly in seconds.


749-749: Update storage call to use ttl_sec_ * 1000.

The update to the storage call to use ttl_sec_ * 1000 ensures that TTL is handled correctly in milliseconds.


766-766: Update cache call to use ttl_sec_.

The update to the cache call to use ttl_sec_ ensures that TTL is handled correctly in seconds.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9e53030 and 5fa3155.

Files selected for processing (11)
  • .github/workflows/pika.yml (2 hunks)
  • src/pika_admin.cc (2 hunks)
  • src/pika_cache_load_thread.cc (1 hunks)
  • src/pika_conf.cc (2 hunks)
  • src/pika_server.cc (5 hunks)
  • src/storage/include/storage/storage.h (15 hunks)
  • src/storage/src/redis.h (7 hunks)
  • src/storage/src/redis_hashes.cc (16 hunks)
  • src/storage/src/redis_strings.cc (22 hunks)
  • src/storage/src/storage.cc (16 hunks)
  • src/storage/tests/keys_test.cc (1 hunks)
Files skipped from review due to trivial changes (4)
  • .github/workflows/pika.yml
  • src/pika_admin.cc
  • src/pika_conf.cc
  • src/pika_server.cc
Files skipped from review as they are similar to previous changes (6)
  • src/pika_cache_load_thread.cc
  • src/storage/include/storage/storage.h
  • src/storage/src/redis_hashes.cc
  • src/storage/src/redis_strings.cc
  • src/storage/src/storage.cc
  • src/storage/tests/keys_test.cc
Additional comments not posted (29)
src/storage/src/redis.h (29)

120-120: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


121-121: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


122-122: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


123-123: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


124-124: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


133-133: Update to milliseconds for timestamp values approved.

The method signature change to use timestamp_millsec instead of timestamp aligns with the PR objectives.


134-134: Update to milliseconds for timestamp values approved.

The method signature change to use timestamp_millsec instead of timestamp aligns with the PR objectives.


135-135: Update to milliseconds for timestamp values approved.

The method signature change to use timestamp_millsec instead of timestamp aligns with the PR objectives.


136-136: Update to milliseconds for timestamp values approved.

The method signature change to use timestamp_millsec instead of timestamp aligns with the PR objectives.


137-137: Update to milliseconds for timestamp values approved.

The method signature change to use timestamp_millsec instead of timestamp aligns with the PR objectives.


145-145: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


146-146: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


147-147: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


148-148: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


149-149: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


159-159: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


160-160: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


164-164: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


172-172: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


174-174: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


175-175: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


176-176: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


188-188: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


189-189: Update to milliseconds for timestamp values approved.

The method signature change to use timestamp_millsec instead of timestamp aligns with the PR objectives.


191-191: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


201-201: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


258-258: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


279-279: Update to milliseconds for TTL values approved.

The method signature change to use ttl_millsec instead of ttl aligns with the PR objectives.


294-294: **Update to

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
src/storage/src/redis.h (2)

188-188: Update all Expire method calls to use millisecond-based TTL values.

The parameter name change from ttl to ttl_millsec indicates that the TTL should be provided in milliseconds. However, there are still instances where the Expire method is called with second-based TTL values. Please update all Expire method calls to ensure the TTL values are in milliseconds.

  • src/pika_kv.cc: Lines 188-188
  • src/storage/tests/lists_test.cc: Lines 188-188
  • src/storage/tests/keys_test.cc: Lines 188-188
  • src/storage/tests/strings_test.cc: Lines 188-188
  • src/storage/tests/sets_test.cc: Lines 188-188
  • src/storage/tests/hashes_test.cc: Lines 188-188
Analysis chain

LGTM! Verify the usage of Expire.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to Expire pass the TTL value in milliseconds.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Expire` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'Expire'

Length of output: 53405


189-189: Ensure all calls to Expireat pass the timestamp in milliseconds.

The search results indicate that there is an instance where time_stamp_sec_ is used directly without conversion to milliseconds. This could lead to incorrect expiration times.

  • File: src/pika_kv.cc
    • Line: db_->cache()->Expireat(key_, time_stamp_sec_);
    • Issue: time_stamp_sec_ should be converted to milliseconds before being passed to Expireat.

Please update this instance to ensure the timestamp is in milliseconds.

Analysis chain

LGTM! Verify the usage of Expireat.

The parameter name change from timestamp to timestamp_millsec is consistent with the objective of handling timestamps in milliseconds.

Ensure that all calls to Expireat pass the timestamp value in milliseconds.


Ensure all calls to Expireat pass the timestamp in milliseconds.

The search results indicate that there are instances where Expireat is called with time_stamp_sec_, which might be in seconds. We need to verify if these instances are correctly converted to milliseconds before being passed to Expireat.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Expireat` pass the timestamp value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'Expireat'

Length of output: 14537


Script:

#!/bin/bash
# Description: Verify if `time_stamp_sec_` is converted to milliseconds before being passed to `Expireat`.

# Search for instances where `time_stamp_sec_` is used in `Expireat` calls.
rg --type cpp 'Expireat\(.*time_stamp_sec_' -A 5

Length of output: 583

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5fa3155 and 37f03a9.

Files selected for processing (1)
  • src/storage/src/redis.h (7 hunks)
Additional comments not posted (15)
src/storage/src/redis.h (15)

122-122: LGTM! Verify the usage of ListsExpire.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to ListsExpire pass the TTL value in milliseconds.


124-124: LGTM! Verify the usage of SetsExpire.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to SetsExpire pass the TTL value in milliseconds.

Verification successful

Verification successful.

The parameter name change from ttl to ttl_millsec has been consistently applied across the codebase, and all calls to SetsExpire pass the TTL value in milliseconds.

  • src/storage/src/redis_strings.cc: Verified usage of SetsExpire with ttl_millsec.
  • src/storage/src/redis_sets.cc: Verified method definition with ttl_millsec.
  • src/storage/src/redis.h: Verified method declaration with ttl_millsec.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetsExpire` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'SetsExpire'

Length of output: 3097


135-135: LGTM! Verify the usage of ListsExpireat.

The parameter name change from timestamp to timestamp_millsec is consistent with the objective of handling timestamps in milliseconds.

Ensure that all calls to ListsExpireat pass the timestamp value in milliseconds.


148-148: LGTM! Verify the usage of ZsetsTTL.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to ZsetsTTL pass the TTL value in milliseconds.

Verification successful

LGTM! Verify the usage of ZsetsTTL.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds. The search results confirm that the function is being called with the new parameter name.

  • src/storage/src/redis_strings.cc: Verified that ZsetsTTL is called with ttl_millsec.
  • src/storage/src/redis_zsets.cc: Verified that the function definition matches the new signature.

Ensure that all calls to ZsetsTTL pass the TTL value in milliseconds.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsTTL` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ZsetsTTL'

Length of output: 1505


123-123: LGTM! Verify the usage of ZsetsExpire.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to ZsetsExpire pass the TTL value in milliseconds.

Verification successful

Verified: All calls to ZsetsExpire pass the TTL value in milliseconds.

The parameter name change from ttl to ttl_millsec is consistent and correctly implemented across the codebase.

  • src/storage/src/redis_strings.cc: ZsetsExpire(key, ttl_millsec, std::move(meta_value))
  • src/storage/src/redis.h: Method declaration with ttl_millsec
  • src/storage/src/redis_zsets.cc: Method definition with ttl_millsec
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsExpire` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ZsetsExpire'

Length of output: 3088


Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsExpire` pass the TTL value in milliseconds.

# Test: Search for all function calls to `ZsetsExpire`. Expect: Only occurrences of the new signature.
rg --type cpp 'ZsetsExpire\('

Length of output: 387


120-120: LGTM! Verify the usage of StringsExpire.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to StringsExpire pass the TTL value in milliseconds.

Verification successful

Verification complete.

The parameter name change from ttl to ttl_millsec is consistent and logical. All calls to StringsExpire pass the TTL value in milliseconds.

  • src/storage/src/redis.h: Method definition.
  • src/storage/src/redis_strings.cc: Method implementation and usage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `StringsExpire` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'StringsExpire'

Length of output: 3017


Script:

#!/bin/bash
# Description: Verify all function calls to `StringsExpire` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp 'StringsExpire\('

Length of output: 397


147-147: LGTM! Verify the usage of ListsTTL.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to ListsTTL pass the TTL value in milliseconds.

Verification successful

Verify all instances of ListsTTL use ttl_millsec.

We need to ensure that all instances of ListsTTL across the codebase use the new parameter name ttl_millsec.


Verification successful.

All instances of ListsTTL in the codebase use the new parameter name ttl_millsec, confirming the change has been consistently applied.

  • src/storage/src/redis_strings.cc
  • src/storage/src/redis.h
  • src/storage/src/redis_lists.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ListsTTL` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ListsTTL'

Length of output: 1437


Script:

#!/bin/bash
# Description: Verify all instances of `ListsTTL` use `ttl_millsec`.

# Test: Search for all occurrences of `ListsTTL` and check the parameter usage.
rg --type cpp 'ListsTTL'

Length of output: 373


134-134: LGTM! Verify the usage of HashesExpireat.

The parameter name change from timestamp to timestamp_millsec is consistent with the objective of handling timestamps in milliseconds.

Ensure that all calls to HashesExpireat pass the timestamp value in milliseconds.


121-121: LGTM! Verify the usage of HashesExpire.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to HashesExpire pass the TTL value in milliseconds.

Verification successful

Verify the usage of HashesExpire across the codebase.

Ensure that all calls to HashesExpire pass the TTL value in milliseconds.


Verification successful.

The parameter name change from ttl to ttl_millsec is consistent across the codebase, and all calls to HashesExpire pass the TTL value in milliseconds.

  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_hashes.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `HashesExpire` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'HashesExpire'

Length of output: 3208


Script:

#!/bin/bash
# Comprehensive search for all usages of `HashesExpire` to verify consistency in parameter usage.

# Search for all occurrences of `HashesExpire` in the codebase.
rg --type cpp -A 5 'HashesExpire'

Length of output: 3208


136-136: LGTM! Verify the usage of SetsExpireat.

The parameter name change from timestamp to timestamp_millsec is consistent with the objective of handling timestamps in milliseconds.

Ensure that all calls to SetsExpireat pass the timestamp value in milliseconds.

Verification successful

Verification Successful: Consistent Usage of timestamp_millsec in SetsExpireat

The parameter name change from timestamp to timestamp_millsec is consistently applied across the codebase, ensuring that all calls to SetsExpireat pass the timestamp value in milliseconds.

  • src/storage/src/redis.h
  • src/storage/src/redis_sets.cc
  • src/storage/src/redis_strings.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetsExpireat` pass the timestamp value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'SetsExpireat'

Length of output: 1602


Script:

#!/bin/bash
# Description: Verify all instances of `SetsExpireat` in the codebase to ensure consistent usage of the `timestamp_millsec` parameter.

# Search for all instances of `SetsExpireat` in the codebase.
rg --type cpp 'SetsExpireat'

Length of output: 413


149-149: LGTM! Verify the usage of SetsTTL.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to SetsTTL pass the TTL value in milliseconds.

Verification successful

Verification Successful!

All calls to SetsTTL pass the TTL value in milliseconds as expected. The parameter name change from ttl to ttl_millsec is consistent and correctly implemented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetsTTL` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'SetsTTL'

Length of output: 1554


Script:

#!/bin/bash
# Description: Verify all function calls to `SetsTTL` pass the TTL value in milliseconds.

# Test: Search for all instances of `SetsTTL` in the codebase.
rg --type cpp 'SetsTTL'

Length of output: 377


137-137: LGTM! Verify the usage of ZsetsExpireat.

The parameter name change from timestamp to timestamp_millsec is consistent with the objective of handling timestamps in milliseconds.

Ensure that all calls to ZsetsExpireat pass the timestamp value in milliseconds.

Verification successful

Verified: The parameter name change from timestamp to timestamp_millsec has been consistently applied across the codebase.

  • src/storage/src/redis.h
  • src/storage/src/redis_strings.cc
  • src/storage/src/redis_zsets.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsExpireat` pass the timestamp value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'ZsetsExpireat'

Length of output: 1577


Script:

#!/bin/bash
# Description: Verify all function calls to `ZsetsExpireat` pass the timestamp value in milliseconds.

# Test: Search for all function calls to `ZsetsExpireat` and ensure they use `timestamp_millsec`.
rg --type cpp 'ZsetsExpireat' -A 2

Length of output: 879


146-146: LGTM! Verify the usage of HashesTTL.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to HashesTTL pass the TTL value in milliseconds.

Verification successful

Ensure TTL values are passed in milliseconds.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds. The search results show the new signature being used in relevant files.

  • Files to check:
    • src/storage/src/redis_strings.cc
    • src/storage/src/redis_hashes.cc

Verify that all calls to HashesTTL, ListsTTL, ZsetsTTL, and SetsTTL pass the TTL value in milliseconds.


Verified: TTL values are passed in milliseconds.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds. The search results confirm that all calls to HashesTTL, ListsTTL, ZsetsTTL, and SetsTTL pass the TTL value in milliseconds.

  • Files verified:
    • src/storage/src/redis_strings.cc
    • src/storage/src/redis_hashes.cc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `HashesTTL` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'HashesTTL'

Length of output: 1524


Script:

#!/bin/bash
# Verify the context around HashesTTL, ListsTTL, ZsetsTTL, and SetsTTL to ensure TTL values are passed in milliseconds.

# Check the context in redis_strings.cc
rg --type cpp -A 10 'HashesTTL|ListsTTL|ZsetsTTL|SetsTTL' src/storage/src/redis_strings.cc

# Check the context in redis_hashes.cc
rg --type cpp -A 10 'HashesTTL' src/storage/src/redis_hashes.cc

Length of output: 1314


145-145: LGTM! Verify the usage of StringsTTL.

The parameter name change from ttl to ttl_millsec is consistent with the objective of handling TTL in milliseconds.

Ensure that all calls to StringsTTL pass the TTL value in milliseconds.

Verification successful

Verified: The parameter name change from ttl to ttl_millsec is consistent and correctly implemented.

The usage of ttl_millsec throughout the codebase confirms that TTL values are being handled in milliseconds as intended.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `StringsTTL` pass the TTL value in milliseconds.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'StringsTTL'

Length of output: 1478


Script:

#!/bin/bash
# Description: Verify all function calls to `StringsTTL` pass the TTL value in milliseconds.

# Test: Search for all calls to `StringsTTL` and check the context to ensure TTL value is in milliseconds.
rg --type cpp 'StringsTTL' -A 3 -B 3

Length of output: 1724


Script:

#!/bin/bash
# Description: Verify that the variables passed to `StringsTTL` represent TTL in milliseconds.

# Test: Search for the definitions and usages of the variables passed to `StringsTTL`.
rg --type cpp 'ttl_millsec' -A 3 -B 3

Length of output: 65757


133-133: LGTM! Verify the usage of StringsExpireat.

The parameter name change from timestamp to timestamp_millsec is consistent with the objective of handling timestamps in milliseconds.

Ensure that all calls to StringsExpireat pass the timestamp value in milliseconds.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 37f03a9 and 3e03f1c.

Files selected for processing (1)
  • src/storage/tests/strings_test.cc (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/storage/tests/strings_test.cc

@AlexStocks AlexStocks merged commit 645da7e into OpenAtomFoundation:unstable Aug 8, 2024
12 checks passed
cheniujh added a commit to chejinge/pika that referenced this pull request Aug 8, 2024
luky116 added a commit to luky116/pika that referenced this pull request Aug 8, 2024
…undation#2822)

* change storage ttl time from seconds to milliseconds

---------

Co-authored-by: liuyuecai <[email protected]>

test space
chejinge added a commit that referenced this pull request Aug 9, 2024
…clear space in CI after compile (#2853)

* fix:remove dependence in CI

* Revert "fix: change storage ttl time from seconds to milliseconds (#2822)"


---------

Co-authored-by: cjh <[email protected]>
Co-authored-by: chejinge <[email protected]>
baerwang pushed a commit that referenced this pull request Sep 3, 2024
* fix: change storage ttl time from seconds to milliseconds (#2822)

* change storage ttl time from seconds to milliseconds

---------

Co-authored-by: liuyuecai <[email protected]>

test space

* fix incr cmd time to millionsseconds

* rename SetRelativeTimeByMillsec to SetRelativeTimeInMillsec

---------

Co-authored-by: liuyuecai <[email protected]>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
…undation#2822)

* change storage ttl time from seconds to milliseconds


---------

Co-authored-by: liuyuecai <[email protected]>
cheniujh added a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
…clear space in CI after compile (OpenAtomFoundation#2853)

* fix:remove dependence in CI

* Revert "fix: change storage ttl time from seconds to milliseconds (OpenAtomFoundation#2822)"


---------

Co-authored-by: cjh <[email protected]>
Co-authored-by: chejinge <[email protected]>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
…undation#2857)

* fix: change storage ttl time from seconds to milliseconds (OpenAtomFoundation#2822)

* change storage ttl time from seconds to milliseconds

---------

Co-authored-by: liuyuecai <[email protected]>

test space

* fix incr cmd time to millionsseconds

* rename SetRelativeTimeByMillsec to SetRelativeTimeInMillsec

---------

Co-authored-by: liuyuecai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0.1 ☢️ Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

floyd save ttl with seconds
4 participants