Cache
Cache copied to clipboard
Allow to cache any objects and arrays, not only strings
I think this class can be much more useful if we can cache any kinds of objects. Just let's store serialized variable, and unserialize it upon cache access.
Also, there needs to be a way to remove a file from cache.
Date: Fri, 28 Nov 2014 11:22:49 -0800 From: [email protected] To: [email protected] Subject: [Cache] Allow to cache any objects and arrays, not only strings (#17)
I think this class can be much more useful if we can cache any kinds of objects. Just let's store serialized variable, and unserialize it upon cache access.
You can merge this Pull Request by running git pull https://github.com/stanishevsky/Cache master Or view, comment on, or merge it at:
https://github.com/Gregwar/Cache/pull/17
Commit Summary
Allow to cache any objects and arrays, not only strings
File Changes
M
Cache.php
(8)
Patch Links:
https://github.com/Gregwar/Cache/pull/17.patch https://github.com/Gregwar/Cache/pull/17.diff
— Reply to this email directly or view it on GitHub.
=
Hello
First, you are doing two things simultaneously, serializing and rehashing filenames, moreover you breaks the unit tests
Regarding serializing/unserializing, I don't think this should be done this way. This system should be useable for caching images or generated pages. Always serializing data would be both useless and overhead for many use cases.
You can add helpers that would have other names like getObject to achieve this
Concerning file hashing, I don't get the point of making it in the cache system, calling sha1 or another logic that hashes before asking the cache is a matter of seconds
thanks for your suggestions
-1 to this. It should be down to the developer to serialize (in the format they want) and not up to the cacher to make these decisions.