3 namespace Caxy\HtmlDiff;
5 use Doctrine\Common\Cache\Cache;
15 protected $cacheProvider;
18 * DiffCache constructor.
20 * @param Cache $cacheProvider
22 public function __construct(Cache $cacheProvider)
24 $this->cacheProvider = $cacheProvider;
30 public function getCacheProvider()
32 return $this->cacheProvider;
36 * @param Cache $cacheProvider
40 public function setCacheProvider($cacheProvider)
42 $this->cacheProvider = $cacheProvider;
48 * @param string $oldText
49 * @param string $newText
53 public function contains($oldText, $newText)
55 return $this->cacheProvider->contains($this->getHashKey($oldText, $newText));
59 * @param string $oldText
60 * @param string $newText
64 public function fetch($oldText, $newText)
66 return $this->cacheProvider->fetch($this->getHashKey($oldText, $newText));
70 * @param string $oldText
71 * @param string $newText
73 * @param int $lifeTime
77 public function save($oldText, $newText, $data, $lifeTime = 0)
79 return $this->cacheProvider->save($this->getHashKey($oldText, $newText), $data, $lifeTime);
83 * @param string $oldText
84 * @param string $newText
88 public function delete($oldText, $newText)
90 return $this->cacheProvider->delete($this->getHashKey($oldText, $newText));
96 public function getStats()
98 return $this->cacheProvider->getStats();
102 * @param string $oldText
103 * @param string $newText
107 protected function getHashKey($oldText, $newText)
109 return sprintf('%s_%s', md5($oldText), md5($newText));