1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: */
11:
12: namespace Nette\Caching\Storages;
13:
14: use Nette;
15:
16:
17:
18: /**
19: * PHP files cache storage.
20: *
21: * @author David Grudl
22: */
23: class PhpFileStorage extends FileStorage
24: {
25: /** @var string */
26: public $hint;
27:
28:
29: /**
30: * Reads cache data from disk.
31: * @param array
32: * @return mixed
33: */
34: protected function readData($meta)
35: {
36: return array(
37: 'file' => $meta[self::FILE],
38: 'handle' => $meta[self::HANDLE],
39: );
40: }
41:
42:
43:
44: /**
45: * Returns file name.
46: * @param string
47: * @return string
48: */
49: protected function getCacheFile($key)
50: {
51: return parent::getCacheFile(substr_replace(
52: $key,
53: trim(strtr($this->hint, '\\/@', '.._'), '.') . '-',
54: strpos($key, Nette\Caching\Cache::NAMESPACE_SEPARATOR) + 1,
55: 0
56: )) . '.php';
57: }
58:
59: }
60: