Does Redis need to set expiration time?

Source: Internet
Author: User
Memcached generally set expire expired automatically deleted, and then

$arr = $mem->get($key);if(empty($arr)){$sql = "select ....";$arr = $pdo->fetch();$mem->set($key,$arr,10*60);}

The Redis PHP API has only one Setex setting expiration time, other list,zset do not see, if not set the cache has been in existence, memory has been increasing? How do I maintain the cache if it is updated?
In fact, I want to ask is the Redis update strategy, ZSET data has been in memory, if the data are updated how to maintain it? If there is a failure period like memcache, but why is it not designed?

Reply content:

Memcached generally set expire expired automatically deleted, and then

$arr = $mem->get($key);if(empty($arr)){$sql = "select ....";$arr = $pdo->fetch();$mem->set($key,$arr,10*60);}

The Redis PHP API has only one Setex setting expiration time, other list,zset do not see, if not set the cache has been in existence, memory has been increasing? How do I maintain the cache if it is updated?
In fact, I want to ask is the Redis update strategy, ZSET data has been in memory, if the data are updated how to maintain it? If there is a failure period like memcache, but why is it not designed?

For the general key with the EXPIRE command. Http://redis.io/commands/expire

Not setting the TTL will of course always exist. The set update overwrites the original value.

List,zset can also set the expiration time, all using the EXPIRE command

It is usually set according to the requirements

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.