Do I need to set the expiration time for redis?

Source: Internet
Author: User
Memcached generally sets expire to automatically delete expired files, and then {code ...} redis's PHPAPI only has one setex to set the expiration time. Other lists and zset are not displayed. If not, the cache that is not set will always exist and the memory will keep increasing? What if the cache is updated? memcached usually sets expire to automatically delete expired files. Then

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

Redis's php api only has one setex to set the expiration time. Other lists and zset are not displayed. If not, the cache is not set and the memory is continuously increasing? How can I maintain the updated cache?
In fact, what I want to ask is the redis update policy. The zset data is always in the memory. How can I maintain updates? If memcache has a poor performance period, why is it not designed?

Reply content:

Memcached generally sets expire to automatically delete expired files, and then

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

Redis's php api only has one setex to set the expiration time. Other lists and zset are not displayed. If not, the cache is not set and the memory is continuously increasing? How can I maintain the updated cache?
In fact, what I want to ask is the redis update policy. The zset data is always in the memory. How can I maintain updates? If memcache has a poor performance period, why is it not designed?

For general keysEXPIRECommand. Http://redis.io/commands/expire

Ttl does not exist all the time.setThe update overwrites the original value.

List, zset can also set the expiration time, both use the EXPIRE command

It is usually set as needed

Related Article

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.