yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Debug Panel should have information about cache #2365

Closed dilip-vishwa closed 8 years ago

dilip-vishwa commented 10 years ago

If the cache is used in page, then we should get some informative information about the cache component used in particular view, query, fragment, or page, etc. It should also show the content of the particular cache.

samdark commented 10 years ago

Which information would you like to have? Getting contents of the cache (keys) is not possible for many backends.

dilip-vishwa commented 10 years ago

Following information can be shown in debug panel:- where cache is set, which type is used for caching data such as apc, file, db,Dummy, redis, wincache, xcache, zendcache, etc., Various conditions, expiration settings and it's duration till now, and all other possible information which can be shown.

This feature will give developer a good understanding of cache working in their web application and also works as a debugger.

samdark commented 10 years ago
  1. where cache is set = log all calls that are setting cache?
  2. which type is used for caching data such as apc, file, db,Dummy, redis, wincache, xcache, zendcache, etc. do you want this info for each call to setting cache?
  3. Various conditions = ?
  4. expiration settings and it's duration till now I'm afraid such info isn't available in many backends at all.
dilip-vishwa commented 10 years ago

The information Various conditions is set by developer or it's default value and for others also same as above.

RomeroMsk commented 10 years ago

It will be usefull to see counters of get/set/delete/flush operations with differentiation by storages - this as minimum. As maximum - list of all opeartions in request: storage, operation (get/set/delete/flush), key, duration (for set).

RomeroMsk commented 10 years ago

It will help to debug pages/requests in these cases, for example:

  1. If I see that same key is getting from cache several times in one request - it's a problem.
  2. If I see unneeded get operations (with keys wich was not used in request) - it's a problem.
  3. I thought that this data is getting from cache, but I see db query instead of cache get operation - maybe I can optimize this code.
  4. When I see unactual or corrupted data on page, I want to know what was the source: db or cache.
  5. I know that this data is storing in cache, but there are db request... Or, wait, 10 seconds duration in set!
kidol commented 9 years ago

Anyone in favor for the event based approach? In yii 1 one had to parse though the log to figure out cache hits/misses. With events, the debug toolbar can listen for class-level events I think:

Event::on(Cache::className(), Cache::EVENT_SET, function ($event) {
    // Collect all results for later
    // $event->sender can be used to figure out cache backend
    // $event might provide: $cacheKey, $success (whether get, set, etc. succeeded)
});

Normal logging like in yii 1 should still be added I guess?

Also a simplified version of the idea

expiration settings and it's duration till now

is possible if cache does store expire timestamp within the cache data (serialize, like with dependency). Then we could see when cache item expires. It could be an optional feature, disabled by default.

yii-bot commented 8 years ago

Issue moved to https://github.com/yiisoft/yii2-debug/issues/76