public function set($name, $value, $ttl = 0){

		if($ttl <= 0) $ttl = self::TTL_FUTURE;

		if(is_resource($value)){

			throw new CacheException('Cannot cache values of type "resource"');
		}

		if(!$this->validateValueSize($value)){

			ExceptionHandler::notice("Value in $name is too big to be stored in file cache.");
		}

		$file = $this->_getFileName($name);

		$fp = @fopen($this->_cache_path . $file, 'wb');

		if(is_resource($fp)){

			$result = @fwrite($fp, serialize($value));
			$result = ($result && @fclose($fp));
			$result =
				($result && @touch($this->_cache_path . $file, time() + $ttl));

			// Clear expired cache-files every once-in-a-while

			if($result && rand(1, self::CLEAR_INTERVAL) == self::CLEAR_INTERVAL){

				$this->_clearExpired();


			}

			return $result;
		}
		else{

			return false;
		}
	}