wp_cache_get not working
-
Hello,
Some strange things happaning,
doing everithing like in documentation or samples in web, butwp_cache_getnot working.. always returningfalseso, my code:
final protected function cacheGet( $update = false ) { $directory = $this->settings->getPath(); $cacheKey = md5( $this->settings->getModule()->getSlug( $directory ) ); $cacheGroup = md5( get_called_class() ); $result = wp_cache_get( $cacheKey, $cacheGroup ); // === false if( false === $result || $update ) { echo '<pre>'; var_dump( 'no cache' ); echo '</pre>'; $result = array(); $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $directory, \FilesystemIterator::SKIP_DOTS ) ); $files = $this->validateFiles( $files ); foreach( $files as $file ) if( ( $content = $this->read( $file ) ) && is_array( $content ) ) $result[] = $content; wp_cache_set( $cacheKey, $result, $cacheGroup, YEAR_IN_SECONDS ); $testCache = wp_cache_get( $cacheKey, $cacheGroup ); // === $result } return $result; }if i try
var_dump( wp_cache_get( $cacheKey, $cacheGroup ) );afterwp_cache_setit returns stored data sowp_cache_setworks fine, but on reload the upperwp_cache_getreturns false, like if cashe is not saved somewhere or not readed when aplication is loaded..due to my aplication these function is called in
plugins_loadedaction or after it ( if plugin is loaded after that action ).
I don’t know, may be it should be loaded after some specific action only ?Also tryed adding
define('WP_CACHE', true);insettings.phpafterWP_DEBUGis defined – same result.Thought may be
$cacheKeyis to long, changed onmy_keyand remuved$cacheGroup– not working.I’m curently running on localhost, with openserver, php5.5, windows10…
Can someone help me ?
The topic ‘wp_cache_get not working’ is closed to new replies.