• Resolved Mihail Semjonov

    (@muxahuk1214)


    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)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_cache_get not working’ is closed to new replies.