wp_cache_get not working
-
Hello,
Some strange things happaning,
doing everithing like in documentation or samples in web, butwp_cache_get
not working.. always returningfalse
so, 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_set
it returns stored data sowp_cache_set
works fine, but on reload the upperwp_cache_get
returns 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_loaded
action 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.php
afterWP_DEBUG
is defined – same result.Thought may be
$cacheKey
is to long, changed onmy_key
and 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.