Home > Code Snippets, PHP > php memcache simulate using file system

php memcache simulate using file system

September 13th, 2011 Leave a comment Go to comments

Recently we were facing some difficulties, where we had facilitate implementing a copy of an application on a development environment with our client. The most difficult part was that though we could coax php to load libraries, we could not install any system services. We were supposed to install only a web application to a pre-configured virtual host. Since we had enjoyed the facility of having Memcache at our own development environment, some core part of the application which was required only when users are logged in, was using the Memcache. Also our database abstraction layer was heavily depending on the memcache library. We immediately identified that the requirements were not met and specified that the environment was not as we required. But the support people were so adamant that they insisted us to proceed by commenting out all references to the class. Well I can also be tough.

I just went online, and did a thorough check to see what all functions from the memcache php object were being used in our system. These methods were rebuilt using a file system wrapper and the same class name. Anyway I am not going to explain the whole code, since the code is commented well. Though cannot hide from some known problems of prolonged usage as well as runaway store.

The getRepos method just returns a folder and a file name, so for a very large and wide implementation, we may reach a bottleneck where too many files in a folder or we might hit the filesystem limit. But that would only be in a 32bit environment, but we need to consider that too. So we disabled the database abstraction memcaching. Though we have auto flush of expired items, there are chances that expired items are never called at all. And this will lead to unwanted files in the repository. Hence a schedule based cleaning for the repository is also needed. Will try to enhance this a bit and release a newer version later on. Also this will not improve the page load speeds to the levels that memcache offers, nor does provide the distributed scale out effect that memcache facilitates.

memcache simulate using files (587)

Categories: Code Snippets, PHP Tags:
  1. No comments yet.
  1. No trackbacks yet.

fifty six + = fifty seven