Cache icon indicating copy to clipboard operation
Cache copied to clipboard

Unable to clear the cache

Open msaus opened this issue 7 years ago • 2 comments

I am getting following error.

PHP Fatal error: Uncaught Desarrolla2\Cache\Exception\CacheException: not ready yet in vendor/desarrolla2/cache/src/Adapter/AbstractAdapter.php:61

It looks like it is not implemented yet.

msaus avatar Sep 15 '17 03:09 msaus

I quickly made removing the cache for file cache. It just gets all cache files and removes if ttl is expired. I added this function to file adapter.

   public function cacheClear()
   {                                                                                                                                                                                                                      
    $files = glob($this->cacheDir.'{*'.self::CACHE_FILE_SUBFIX.'}',GLOB_BRACE);                                                                                                                                          
     $count = count($files);                                                                                                                                                                                        
     for($i = 0 ; $i < $count ; $i++)                                                                                                                                                                               
     {                                                                                                                                                                                                              
       $data = $this->unpack(file_get_contents($files[$i]));                                                                                                                                                        
       if($this->ttlHasExpired($data['ttl']))                                                                                                                                                                       
       {                                                                                                                                                                                                            
         $this->deleteFile($files[$i]);                                                                                                                                                                             
       } 
       unset($files[$i]);                                                                                                                                                                                                                 
      }                                                                                                                                                                                                              
      return true;                                                                                                                                                                                                       
     }  

msaus avatar Sep 15 '17 05:09 msaus

Can you send a PR?

desarrolla2 avatar Sep 15 '17 11:09 desarrolla2