cache.php 612 Bytes
Newer Older
Benjamin Adams's avatar
Benjamin Adams committed
1
2
3
4
5
6
7
8
9
10
11
12
<?php

add_action('transition_post_status', 'refresh_wp_redis_cache',10,3);

//clears the cache after you update a post
function refresh_wp_redis_cache( $new, $old, $post )
{

if($new == "publish")
{
$permalink = get_permalink( $post->ID );

13
14
// aaronstpierre: this needs to be include_once so as not to cauase a redeclaration error
include_once("predis5.2.php");  //we need this to use Redis inside of PHP
Benjamin Adams's avatar
Benjamin Adams committed
15
16
17
18
$redis = new Predis_Client();

$redis_key = md5($permalink);
$redis->del($redis_key);
19
20
21
22
23

//refresh the front page
$frontPage = get_home_url() . "/";
$redis_key = md5($frontPage);
$redis->del($redis_key);
Benjamin Adams's avatar
Benjamin Adams committed
24
}
25
}