Joined May 2013
·
Achievements
62 Karma
0 Total ProTip Views
Nephila Komaci
Have at least one original repos where PHP is the dominant language
Nephila Komaci 3
Have at least three original repos where PHP is the dominant language
Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos
Forked
Have a project valued enough to be forked by someone else
Charity
Fork and commit to someone's open source project in need
Lab
Have at least one original repo where C# is the dominant language
Nice, though I see some potential problems here I'd recommend to fix before putting it into Apex
Unix issues:
1. mkdir 777
Code issues:
2. action = null, next line action = something
3. if and elseif that does the same should be replaced by OR
4. storing last action is useless, and php is stateless
Concurrency issues
4. fopen(.., 'c') doesnt truncate file, therefore new shorter cached content will replace old one only partially, forming an incorrect file content and invalid json
5.flock + fwrite in userland is way slower then just fileputcontents and same logic implemented in C land. May be critical and if someone decides to intentionally load a page using it multiple times in parallel.
6. fclose outside of try-finally may never happen, same about flock(lock_un). critical if you suddenly decide to use this in a command line app.
7. destroy traverses directory instead of directly accessing file. Very IO expensive and performance slow
General issues:
8. hardcoded config (cache dir)
9. no parameters validation. $expire can be not int and name can be "../../index.php".
10. error suppressing with @
Architecture issues:
11. Static is not testable as every test case will have side effects on other classes
12. It's not injectable as dependency, therefore other classes will result strongly coupled on it.
13. It is not replaceable. You cannot substitute file cache with apc cache when time comes.
Woot?
14. File as cache? You really don't have apc or memcache ?
15. There are more comments then code (and more issues then code as well)
16. One of the strongest parts of php is the wide range of libraries ready out there. Just use of of the existing caching implementations.
Other then that, not bad ;)