I am currently building a caching component for my applications. It will have support for different adapters:
- APC
- Memcached
- Files
For all of them, I need to generate a cache key for them. What’s the best way to do this? I am considering contatenating the function name and arguements and then running md5() on it. Is this a good strategy?
Finally, when caching objects as files to disk, how should the cache files be organized? I have a feeling that having a cache folder and just throwing all the cache files in there would probably be pretty bad performance.
The application will be hosted on Linux and Windows servers.
Both md5() and sha1() fit your need to name cache files, since they both have a good performance.
When saving the cache files to the file system, you can refer to how git store its files.
Links useful:
Benchmark: http://www.cryptopp.com/benchmarks.html
How git stores objects: http://book.git-scm.com/7_how_git_stores_objects.html