DeanWhitehouse Posted February 25, 2012 Share Posted February 25, 2012 I wrote a short article/tutorial about session caching in PHP and was just looking for tips on both my code and my article. Any feedback would be great please. http://www.deanwhitehouse.co.uk/session-caching-v1-0 I also wrote one on how to do cross-domain ajax calls using jquery. http://www.deanwhitehouse.co.uk/cross-domain-request-with-jquery Cheers, Dean Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/ Share on other sites More sharing options...
trq Posted February 25, 2012 Share Posted February 25, 2012 Sorry but I don't really see any benefit in using this SessionCache class over the standard $_SESSION array. Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321023 Share on other sites More sharing options...
ignace Posted February 25, 2012 Share Posted February 25, 2012 Also the class name implies it's something it's not and your class actually violates SRP and the OCP principle. Since your class is responsible for both _SESSION and encryption of the data. Everytime the encryption of your session changes you have to go in the sessioncache class and change it, which is more prone to break existing code. Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321049 Share on other sites More sharing options...
DeanWhitehouse Posted February 25, 2012 Author Share Posted February 25, 2012 Thorpe: It just makes it easier to store items in a session and retrieve them when implementing on a website where you are unsure of the possible $_SESSION index names. It's basically just a few functions to manage a sites session caching instead of a user writing their own. Would only take a few minutes to re-create the functions yourself so I can see how it may seem pointless. ignace: I'm afraid I don't see how the class name is misleading, could you please expand. Thank you for the links I'm not very experienced in OOP design or guidelines such as them so will be good for me to learn. Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321104 Share on other sites More sharing options...
ignace Posted February 25, 2012 Share Posted February 25, 2012 From Wikipedia: a cache is a component that transparently stores data so that future requests for that data can be served faster. You are still using the PHP implementation for sessions (ie, the filesystem) also options like cache lifetime and such are missing. It's thus misleading. Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321171 Share on other sites More sharing options...
DeanWhitehouse Posted February 25, 2012 Author Share Posted February 25, 2012 All caching methods have to store the data in some form of file. I can see how a user could mis-interpret the name as a way to cache a session instead of a way to cache data using sessions, i think that is what you're going for Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321175 Share on other sites More sharing options...
gizmola Posted February 25, 2012 Share Posted February 25, 2012 All caching methods have to store the data in some form of file. I can see how a user could mis-interpret the name as a way to cache a session instead of a way to cache data using sessions, i think that is what you're going for Yes, I have to agree. I think it's fine if you're trying to do something more with base sessions, for example adding namespacing as the zend_session does, but caching is highly misleading, because there is arguably no caching going on in your class. If it was clearer what problems you were trying to solve, and what benefit this approach has over the use of basic sessions, I think the article would be a lot more valuable. As it is now, it's hard to provide much positive feedback. Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321264 Share on other sites More sharing options...
DeanWhitehouse Posted February 26, 2012 Author Share Posted February 26, 2012 That is true, i'm using the class myself to store user configuration options retrieved from a database. Therefore it is cached from another data source. I wasn't trying to solve a problem per-say, but just create a simple re-usable system for storing such data. Quote Link to comment https://forums.phpfreaks.com/topic/257736-article-review-session-caching-in-php/#findComment-1321295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.