Advertisement
_officialdave

Yp_cache_file_directory

Aug 14th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by JetBrains PhpStorm.
  4.  * User: David
  5.  * Date: 6/12/12
  6.  * Time: 9:35 AM
  7.  * To change this template use File | Settings | File Templates.
  8.  */
  9. include_once 'Yp_cache_file.php';
  10.  
  11. class Yp_cache_file_directory extends Yp_cache
  12. {
  13.     private $dir = '';
  14.     private $ext = 'cache';
  15.  
  16.     function get_file_full_path($key, $type='') {
  17.         $file_name = $key;
  18.         if($type!='') $file_name .= '-'.$type;
  19.         $file_name = $this->getDir().'/'.$file_name.'.'.$this->getExt();
  20.         return $file_name;
  21.     }
  22.  
  23.     function cache_flush() {
  24.         //delete all files
  25.         $mask = $this->getDir().'/*.'.$this->getExt();
  26.         array_map( "unlink", glob( $mask ) );
  27.     }
  28.  
  29.     public function setDir($dir)
  30.     {
  31.         $this->dir = $dir;
  32.     }
  33.  
  34.     public function getDir()
  35.     {
  36.         return $this->dir;
  37.     }
  38.  
  39.     public function setExt($ext)
  40.     {
  41.         $this->ext = $ext;
  42.     }
  43.  
  44.     public function getExt()
  45.     {
  46.         return $this->ext;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement