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

LASTSAVE Command to Return Human-Readable Timestamp. #2817

Open
2 tasks done
SharonIV0x86 opened this issue Mar 6, 2025 · 5 comments · May be fixed by #2822
Open
2 tasks done

LASTSAVE Command to Return Human-Readable Timestamp. #2817

SharonIV0x86 opened this issue Mar 6, 2025 · 5 comments · May be fixed by #2822
Assignees
Labels
enhancement type enhancement

Comments

@SharonIV0x86
Copy link
Contributor

Search before asking

  • I had searched in the issues and found no similar issues.

Motivation

While i was working with creating backups in the kvrocks i wanted to see the time when the last save was done, i ran the LASTSAVE command and it returned the time in the unix epoch timestamp.

Solution

I’d like to propose an improvement to the LASTSAVE command by using the <ctime> library to convert the Unix timestamp into a human-readable local time format.

Currently, LASTSAVE returns the time in Unix epoch format, which requires users to manually convert it to their local time. This can be a bit time-consuming.

I have two solutions for this.
1.) Introduce a new command LASTSAVEH
This command would return the last save time in a human-readable format (e.g., 2025-03-06 21:54:51). The existing LASTSAVE command would remain unchanged, continuing to return the Unix timestamp.
2.) Modify LASTSAVE to return both formats
Instead of introducing a new command, we could modify LASTSAVE to return two values:

  • The Unix timestamp (for backward compatibility).
  • The formatted timestamp (for better readability).

I am happy to work on this enhancement, if you find my idea relevant kindly assign this to me. 😄

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@SharonIV0x86 SharonIV0x86 added the enhancement type enhancement label Mar 6, 2025
@git-hulk
Copy link
Member

git-hulk commented Mar 7, 2025

@SharonIV0x86 Perhaps we could add an option for the LASTSAVE command? For example, like LASTSAVE [format], it will remainly return the timestamp if the option is omitted.

@SharonIV0x86
Copy link
Contributor Author

SharonIV0x86 commented Mar 7, 2025

@SharonIV0x86 Perhaps we could add an option for the LASTSAVE command? For example, like LASTSAVE [format], it will remainly return the timestamp if the option is omitted.

Something like this?
LASTSAVE h
Or
LASTSAVE human
Or
LASTSAVE iso8601

@git-hulk
Copy link
Member

git-hulk commented Mar 7, 2025

Yes, I prefer using the format: LASTSAVE ISO8601. cc @PragmaTwice @torwig @mapleFU

@SharonIV0x86
Copy link
Contributor Author

Yes, I prefer using the format: LASTSAVE ISO8601. cc @PragmaTwice @torwig @mapleFU

Sounds good. I'd like to implement this enhancement and I'll also modify the docs accordingly.

@torwig
Copy link
Contributor

torwig commented Mar 7, 2025

ISO8601 is OK for me. However, can we make it case insensitive, so both ISO8601 and iso8601 will work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement type enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants