# autoptimize/0.5/classes/autoptimizeCache.php

Autoptimize, version 0.5. 41 lines.

- Page: https://pluginprobe.com/plugins/autoptimize/0.5/code/classes/autoptimizeCache.php
- Raw: https://pluginprobe.com/plugins/autoptimize/0.5/raw/classes/autoptimizeCache.php
- Modified: 2009-07-09T18:22:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/autoptimize/0.5/code/classes/autoptimizeCache.php#L10-L20`.

```php
<?php

class autopimizeCache
{
	private $filename;
	private $mime;
	private $cachedir;
	
	public function __construct($cachedir,$md5)
	{
		$this->cachedir = $cachedir;
		$this->filename = 'autoptimize_'.$md5.'.php';
	}
	
	public function check()
	{
		if(!file_exists($this->cachedir.$this->filename))
		{
			//No cached file, sorry
			return false;
		}
		//Cache exists!
		return true;
	}
	
	public function cache($code,$mime)
	{
		$phpcode = file_get_contents(WP_PLUGIN_DIR.'/autoptimize/config/default.php');
		$phpcode = str_replace(array('%%CONTENT%%','exit;'),array($mime,''),$phpcode);
		file_put_contents($this->cachedir.$this->filename,$phpcode);
		file_put_contents($this->cachedir.$this->filename.'.deflate',gzencode($code,9,FORCE_DEFLATE));
		file_put_contents($this->cachedir.$this->filename.'.gzip',gzencode($code,9,FORCE_GZIP));
		file_put_contents($this->cachedir.$this->filename.'.none',$code);
	}
	
	public function getname()
	{
		return $this->filename;
	}
}

```
