Answer the question
In order to leave comments, you need to log in
How can I specify the content version in redis and then compare it with the new number?
Good afternoon, help me figure it out, you need to implement the removal of old keys from redis if the version has been updated, there is such a script that caches the desired piece on the page
. block
if ($current_user->user_login == 'admin'){
$key = $pname.'_first_admin_'.get_field('admin_version');
if ($redis->exists($key)) {
echo $redis->get($key);
} else {
$content20 = get20($bild_20,$pname);
// вычисляете свой кусок, затем
$redis->set($key, $content20);
//$redis->expire($key, 2592000); // 1 месяц
echo $redis->get($key);
}
}
else
{
$key = $pname.'_first_user_'.get_field('user_version');
if ($redis->exists($key)) {
echo $redis->get($key);
} else {
$content20 = get20($bild_20,$pname);
// вычисляете свой кусок, затем
$redis->set($key, $content20);
//$redis->expire($key, 2592000); // 1 месяц
echo $redis->get($key);
}
}
test_first_admin_1
test_first_user_1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question