Skip to content

Commit

Permalink
+ Not sure this'll work 100% because I neither have opcache nor APC i…
Browse files Browse the repository at this point in the history
…nstalled on my current test server, but apparently it's a good thing to invalidate stuff. Needs testing. (Subs-Cache.php)
  • Loading branch information
Nao committed Mar 11, 2017
1 parent 1fcd685 commit ded9e47
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/app/Subs-Cache.php
Expand Up @@ -1910,12 +1910,23 @@ function cache_put_data($key, $val, $ttl = 120)
if (file_put_contents(CACHE_DIR . '/keys/' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data))
@unlink(CACHE_DIR . '/keys/' . $key . '.php');
}
invalidate_opcache($key);
}

if (!empty($db_show_debug))
$cache_hits[$cache_count]['t'] = microtime(true) - $st;
}

function invalidate_opcache($key)
{
// Invalidate opcode and APC caches if available.
if (function_exists('opcache_invalidate'))
opcache_invalidate(CACHE_DIR . '/keys/' . $key . '.php', true);

if (function_exists('apc_delete_file'))
apc_delete_file(CACHE_DIR . '/keys/' . $key . '.php');
}

/**
* Attempt to retrieve an item from cache, previously stored with {@link cache_put_data()}.
*
Expand Down Expand Up @@ -1954,7 +1965,10 @@ function cache_get_data($orig_key, $ttl = 120, $put_callback = null)
{
include(CACHE_DIR . '/keys/' . $key . '.php');
if (empty($valid))
{
@unlink(CACHE_DIR . '/keys/' . $key . '.php');
invalidate_opcache($key);
}
}

if (!empty($db_show_debug))
Expand Down

0 comments on commit ded9e47

Please sign in to comment.