Right now I am still working on the ground level i.e. the smwStore as many things can be optimized there; for e.g. on each page edit all the smw data is rewritten to the database even if nothing was changed.

Soon after I complete working on the smwStore I will look into Caching Queries and SpecialPages.
However, your implementation will be helpful.

I did a similar thing with wgMemc for a SpecialPage of SMW.

global $wgMemc;
$key = $this->getName(); // we use the Name as the cache key
$key = $key.$limit.$offset; // modified key to contain limit and offset information
$res = $wgMemc->get($key);

if($res == '' || $nocache == true){//Check to see if cache is old or empty
$res = $this->getResults( $options );
$wgMemc->set( $key, $res, 60 * 60 ); //update the cache with expiration time 1 hour ( can be changed )
$wgOut->addHTML( "<p>This is a cached result</p>" );

On Wed, May 30, 2012 at 3:25 AM, Jeroen De Dauw <jeroendedauw@gmail.com> wrote:
Hey James,

Great that you are looking into this. Are you aware of Nicschayns Summer of Code project [0]? He'll be doing stuff in this direction. Better coordinate to avoid both doing the same work in parallel :)

I think your approach is good in general, as an easy-to-implement tweak that can have quite a big impact on performance even though not as much as more complex caching strategies might.

> public function getHash() { return md5( $this->m_querystring . $this->m_limit . serialize( $this->m_extraprintouts ) ); }

Since stuff here is not sorted, you can have the same query with different hashes. Might be easy to sort in some way and not have this.

> The cache object is generated using the $wgMemc class

I'm in favor of using wfGetCache( CACHE_ANYTHING ).

Why? wgMemc works whether you use Memc or not. And memc gives the best performance.
To wrap up: I think this is ok, although the integration could be better. One concern I have is that if this is enabled, and you change something that you want to see reflected in your query right away, there is no way to invalidate the cache. If that gets addressed, such a change can go in SMW as far as I'm concerned. Improving the integration can be done later, although this might not be much later, depending on Nicschayns progress.

[0] https://www.mediawiki.org/wiki/User:Nischayn22/Gsoc


Jeroen De Dauw
Don't panic. Don't be evil.

Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Semediawiki-devel mailing list


Nischay Nahata