milesj / utility

[Deprecated] A CakePHP plugin for common utility classes.
MIT License
69 stars 24 forks source link

More consistent use of internal cache ($_cached) #29

Closed Ali1 closed 10 years ago

Ali1 commented 10 years ago

Firstly, this pull incorporates some clean up of my previous coding as I am more familiar with the Cache class. Secondly, I am not sure whether you intended for $_cache to be a functioning internal cache for the request to avoid multiple cache hits as the code is a bit inconsistent. In this commit, I ensure that any read or write to the cache acts as a primer for any future reads to avoid multiple identical hits to memcached/wincache/file in the same request.

Later, I'll do some work incorporating the new Cache::readMany implementation in Cake (https://github.com/cakephp/cakephp/pull/3313). Probably a readManyCache in this behaviour to use for example when you are sure you are going to x, y and z keys in this current request.

milesj commented 10 years ago

Can you verify that the DB is not hit consecutively for the same query?

As for the Cache::readMany changes, that is not necessary. That is 3.0 code and this plugin is only for 2.x. Furthermore, this plugin is deprecated, so no further development will occur.

Ali1 commented 10 years ago

Oh how come you're depreciating? Time? Or is it because of cake3 has more features?

You mean the cache is not hit consecutively? I'll do some tests.

milesj commented 10 years ago

Because I don't develop in CakePHP anymore, and all old projects are no longer being maintained.

And yes, just verify it hits correctly and I'll merge it in. The code looks like it should work, just have no easy way to test it.

Ali1 commented 10 years ago

I can confirm it works well whether through a $model->find, or directly through $model->readCache. Out of interest, you using titon for new web developments?

milesj commented 10 years ago

Cool, looks good to me. Thanks!

I use Laravel at work, and Titon for any personal projects I have.