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