WINCACHE 1.0 RC - New cool features

I will be talking about some new features we have coded in WINCACHE RC release. We have introduced new API and changes/additions to the WINCACHE INI directives. I am going to explain two new improvements we have done over Beta release which will dictate how WINCACHE is going to cache the file.

  • We have exposed a new function wincache_refresh_if_changed(). This API forces WINCACHE to check for the file change for the files mentioned in the parameter next time the file gets loaded. So this effectively means bypassing the wincache.chkinterval value.The parameter takes the below values:
    • A simple string which is a way to pass one single file name
    • An array of strings where one can specify an array of file names
    • NULL meaning every single file

One important thing to note here is that this API just forces WINCACHE to check for a file change on every request of loading the file. This will not remove the file from the cache unless the file has actually changed. So if there are files in your application which changes dynamically or frequently it is probably a good idea to add those in list by using this API. A good example is 'config.php' file in major PHP applications. This is the file which stores all your configuration and is a good candidate to add to the list as you will probably want the changes (like change of password etc) to get reflected immediately rather than waiting for the interval being set by wincache.interval INI directive. The calls to this API is cumulative in nature. This means the successive call adds to the list and doesn't override the original list. Look at below example:

<?php

require_once('inc1.php');
require_once('inc2.php');

wincache_refresh_if_changed('inc1.php');
wincache_refresh_if_changed('inc2.php');
?>

The above code ensures that both files 'inc1.php' as well as 'inc2.php' are added to the list and if anyone gets modified the changes will take place immediately.

And remember this takes priority over whatever value wincache.chkinterval is set to. This will be important when you will know about the next feature.

  • Another thinking that we debated in our feature team meeting was how often PHP file within your application will change. I believe it will not be very often that you will change your PHP files. So I am introducing to you this cool value of '0' which can be set as part of wincache.chkinterval. This will ensure that file once cached will never be checked for the condition if it has changed or not. And this applies to all the files. Now I believe this with the above feature will make a great combination. You know which files may change (and is small). Probably you will like to add them to refresh list using the above API and set wincache.chkinterval to '0'. Since the above API takes priority it will ensure that files which gets changed will be checked and others will never get checked.

I think these two new features will make a great combination if used in the right way.

I hope you will like these features. Want some feature which is missing, feel free to leave your comment here. I will be so happy to represent your feelings in our feature team meetings. Like these features, well kudos are always welcome. It serves a big motivation for us.

Thanks for the patient reading and good bye.

Regards,

Don

No Comments