Title: wp_cache_get not working
Last modified: August 30, 2016

---

# wp_cache_get not working

 *  Resolved [Mihail Semjonov](https://wordpress.org/support/users/muxahuk1214/)
 * (@muxahuk1214)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/wp_cache_get-not-working/)
 * Hello,
 * Some strange things happaning,
    doing everithing like in documentation or samples
   in web, but `wp_cache_get` not working.. always returning `false`
 * 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 ) );` **after** `wp_cache_set`
   it _returns stored data_ so `wp_cache_set` works fine, but on reload the upper`
   wp_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);` in `settings.php` after `WP_DEBUG`
   is defined – same result.
 * Thought may be `$cacheKey` is to long, changed on `my_key` and remuved `$cacheGroup`–
   not working.
 * I’m curently running on localhost, with openserver, php5.5, windows10…
 * Can someone help me ?

Viewing 1 replies (of 1 total)

 *  Thread Starter [Mihail Semjonov](https://wordpress.org/support/users/muxahuk1214/)
 * (@muxahuk1214)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/wp_cache_get-not-working/#post-6484169)
 * `By default, the object cache is non-persistent. This means that data stored 
   in the cache resides in memory only and only for the duration of the request.
   Cached data will not be stored persistently across page loads unless you install
   a persistent caching plugin.`
    [https://codex.wordpress.org/Class_Reference/WP_Object_Cache](https://codex.wordpress.org/Class_Reference/WP_Object_Cache)
 * Didn’t saw that…
 * Ughm.. If i turn on transients then it runs slower with it than without transients..

Viewing 1 replies (of 1 total)

The topic ‘wp_cache_get not working’ is closed to new replies.

## Tags

 * [WP_CACHE](https://wordpress.org/support/topic-tag/wp_cache/)
 * [wp_cache_get](https://wordpress.org/support/topic-tag/wp_cache_get/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Mihail Semjonov](https://wordpress.org/support/users/muxahuk1214/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/wp_cache_get-not-working/#post-6484169)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
