Home  >  Article  >  Backend Development  >  PHP gets Memcached's cas_token

PHP gets Memcached's cas_token

藏色散人
藏色散人forward
2019-04-28 14:24:202297browse

This article mainly introduces how to obtain Memcached's cas_token in PHP. I hope it will be helpful to friends in need!

php official method code

$ips = $m->get('ip_block', null, $cas);

According to the code provided by php official documentation to obtain cas_token, the result $cas is always null, after checking for a long time, it turns out that the way to obtain cas_token is in php5 and php7 It’s a different

php5 method

$ips = $m->get('ip_block', null, $cas);
var_dump($cas);

php7method

$_val = $m->get('ip_block', null, Memcached::GET_EXTENDED);
var_dump($_val['cas']);

make a judgment

$cas = null;
if (defined(Memcached::GET_EXTENDED)){
    $_val = $m->get('ip_block', null, Memcached::GET_EXTENDED);
    $cas = $_val['cas'];
} else {
    $ips = $m->get('ip_block', null, $cas);
}
var_dump($cas);

Related recommendations:《PHP tutorial

The above is the detailed content of PHP gets Memcached's cas_token. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jmsite.cn. If there is any infringement, please contact admin@php.cn delete