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: * PHP files cache storage.
19: *
20: * @author David Grudl
21: */
22: class PhpFileStorage extends FileStorage
23: {
24: /** @var string */
25: public $hint;
26:
27:
28: /**
29: * Reads cache data from disk.
30: * @param array
31: * @return mixed
32: */
33: protected function readData($meta)
34: {
35: return array(
36: 'file' => $meta[self::FILE],
37: 'handle' => $meta[self::HANDLE],
38: );
39: }
40:
41:
42: /**
43: * Returns file name.
44: * @param string
45: * @return string
46: */
47: protected function getCacheFile($key)
48: {
49: return parent::getCacheFile(substr_replace(
50: $key,
51: trim(strtr($this->hint, '\\/@', '.._'), '.') . '-',
52: strpos($key, Nette\Caching\Cache::NAMESPACE_SEPARATOR) + 1,
53: 0
54: )) . '.php';
55: }
56:
57: }
58: