Description
- bug report -
NO
- feature request -
YES
- version: >2.4.0
What's about
A few days ago I was working on cache panel. My goal was to show all created cache files with expiration, size and many other things. It was quite easy, let say with little help of reflection.
My result look's like that.
The thing is I cannot show cache key, because it's serialized in Cache object and passed to IStorage. I was reading it from FileStorage (that was my 1st implementation) and there is only md5 hash. I known I can inherit Cache object or create CacheFactory a everything gonna be allright, but I wont. I would like to see it also in my old projects.
Why it might be useful? At this time we have no cache tools or any other cache introspective tools. We can only create Cache object with IStorage and hope there's a cache file with this key (hash).
How to implement it
1) CacheFactory + inherit Cache object
It's good but only for new projects.
2) Store cache key under special tag
I think it's oukey, but little bit tricky.
$dependencies[Cache::TAGS] = ['__nette.cache.key' => $key];
$this->storage->write($key, $data, $dependencies);
3) Introduce new constant Cache::KEY
I consider this as best solution. It's clean and it shouldn't broke any existing code.
$dependencies[Cache::KEY] = $key;
$this->storage->write($key, $data, $dependencies);
What do you think guys? @dg @fprochazka @TomasVotruba @matej21 @JanTvrdik