How do I change the default cache time for memcached?

Source: Internet
Author: User
Tags memcached

When we use PHP's memcached extension to add data to the memcached, there are two ways in which the data will be available in time. Such as.

As for the setting of a Unix timestamp or an integer in seconds (from the current calculated time difference) to indicate the expiration of this data, but in the latter setting, not more than 2.592 million seconds (30 days) problem What should we do? We don't want to be permanently valid, but we don't want to limit it to 30 days. So here's the way, here's the code for the official document as the sample code, as follows.

<?php

$memcache _obj = Memcache_connect ("localhost", 11211);

/* For process 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

?>

More on the article please focus on love Blog

How do I change the default cache time for memcached?

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.