Skip to content

Instantly share code, notes, and snippets.

@jbma
Last active December 15, 2015 15:19
Show Gist options
  • Save jbma/5281220 to your computer and use it in GitHub Desktop.
Save jbma/5281220 to your computer and use it in GitHub Desktop.
Vider cache redis à la publicaiton
<?php
add_action ('save_post','purge_redis');
function purge_redis (){
include ('predis.php');
$redis = new Predis\Client('');
$domain = $_SERVER['HTTP_HOST'];
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url = str_replace('?r=y', '', $url);
$url = str_replace('?c=y', '', $url);
$dkey = md5($domain);
$ukey = md5($url);
if ($redis->exists($dkey)) {
$redis->del($dkey);
}
}// fin fonction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment