Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:17:45+00:00 2026-06-09T06:17:45+00:00

My redis server does not delete keys when the time-to-live reaches 0. Here is

  • 0

My redis server does not delete keys when the time-to-live reaches 0.

Here is a sample code:

redis-cli
>SET mykey "ismykey"
>EXPIRE mykey 20
#check TTL
>TTL mykey
>(integer) 17
> ...
>TTL mykey
>(integer) -1
#mykey chould have expired:
>EXISTS mykey
>(integer) 1
>#oh still there, check its value
>GET mykey
>"ismykey"

If i check the info return by redis, it says 0 keys were expired.

Any idea?

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:17:47+00:00Added an answer on June 9, 2026 at 6:17 am

    Since you’re doing a ‘…’ it’s hard to say for sure, but I’d say you’re setting mykey during that part, which will effectively remove the expiration.

    From the EXPIRE manual

    The timeout is cleared only when the key is removed using the DEL
    command or overwritten using the SET or GETSET commands

    Also, regarding the -1 reply from TTL

    Return value

    Integer reply: TTL in seconds or -1 when key does not
    exist or does not have a timeout.

    EDIT: Note that this behaviour changed in Redis 2.8

    Starting with Redis 2.8 the return value in case of error changed:
    The command returns -2 if the key does not exist.
    The command returns -1 if the key exists but has no associated expire.

    In other words, if your key exists, it would seem to be persistent, ie not have any expiration set.

    EDIT: It seems I can reproduce this if I create the key on a REDIS slave server, the slave will not delete the key without master input, since normally you would not create keys locally on a slave. Is this the case here?

    However while the slaves connected to a master will not expire keys
    independently (but will wait for the DEL coming from the master),
    they’ll still take the full state of the expires existing in the
    dataset, so when a slave is elected to a master it will be able to
    expire the keys independently, fully acting as a master.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

after shutting down the redis server, the values stored using set is destroyed, here
Context I have a live running redis-server. I want to make a backup. Idea:
How to check whether the Redis server is running? If it's not running, I
I can start the redis server but it seems that I can not start
Unfortunately, the redis-py library does not seem to have a Monitor routine. I would
We're using a Ruby web-app with Redis server for caching. Is there a point
I'm integrating redis into my NodeJS server app, and I'm trying to figure out
Premise Hi, I received multiple reports from a Redis user that experienced server crashes,
If redis gets overloaded, can I configure it to drop set requests? I have
Does anybody know how to redirect to another server/solution using ASP.NET MVC? Something like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.