How can I change the default cache time of memcached ?, Memcached Cache

Source: Internet
Author: User

How can I change the default cache time of memcached ?, Memcached Cache

When we use the memcached extension of php to add data to memcached, there are two methods for data validity. For example.

AsSet a UNIX timestamp or an integer in seconds (time difference from the current time) to indicate the data expiration time. However, in the next setting method, cannot exceed 2592000 seconds (30 days)What should we do? We do not want to set it to permanently valid, but we do not want to limit it to 30 days. Here we use the code in the official document as an example code, as shown below.

<? Php

$ Memcache_obj = memcache_connect ("localhost", 11211 );

/* Process-oriented programming API */
Memcache_add ($ memcache_obj, 'var _ key', 'test variable', false, 0); // permanently valid

/* Object-Oriented Programming API */
$ Memcache_obj-> add ('var _ key', 'test variable', false, time () + 24*60*60*30); // more than 30 days

?>

For more articles, please pay attention to love blog

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.