Some Cache / MUC questions

Some Cache / MUC questions

by Howard Miller -
Number of replies: 7
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ever hopeful of a reply...

I have set up memcached on a remote server and want to see if it is an improvement over the file cache. However, on the performance test page it is listed as 'Untestable'. Why? 

If I edit the mapping I get an option for 'Primary store' and 'Final store'. What does this mean? I can't find any documentation anywhere.

The documentation (or lack thereof) for this complex page is a bit worrying. This is latest 2.5 by the way. 

Average of ratings: -
In reply to Howard Miller

Re: Some Cache / MUC questions

by Ron Meske -
Picture of Particularly helpful Moodlers

Howard, Did you ever get an answer as to what the difference between "Primary store" and "Final store" is?

I would hazard a guess that Primary store is the first location Moodle goes to look for a cached item.  If it is not found, perhaps it than checks the Final store?  For reading that makes sense, but what about writing to the cache, does it write to both?

In reply to Ron Meske

Re: Some Cache / MUC questions

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Nope. Not a thing. Oddly, I was just looking at this in the last few days and thinking again that I have no idea what it means. 

It's not very good is it.... mixed

In reply to Howard Miller

Re: Some Cache / MUC questions

by Ron Meske -
Picture of Particularly helpful Moodlers

It is quite strange.  You would think that this would be documented somewhere especially for developers so they know how to make use of it.

In reply to Ron Meske

Re: Some Cache / MUC questions

by Sam Hemelryk -
My apologies, I should have written the documentation long ago but it appears the task was a bit like kryptonite to me, there was always something to distract me/pull me away.
I've made a start into it today, dedicating much of the day to it - you can see where I'm up to here: http://docs.moodle.org/dev/User:Sam_Hemelryk/Caching

It is still a work in progress - I will dedicating all the time I can to it tomorrow. Once finished it will be moved into the version documentation where it belongs (after I get Helen to aid me in fixing it up)

In answer to your question:

MUC allows for one or more cache store instances to be mapped to a cache definition. This is basically saying you can use one or more backends to store data for a single cache.
If multiple stores have been mapped the following occurs:
* When looking for something in the cache the stores get chained in the order they are mapped. First MUC looks at the primary store. If the primary store doesn't have the data then the primary store looks at the next store in the chain, and so on until either it is found in one of the chained stores or there are no more stores to search.
If it is found in a store down the chain then each store back up the chain sets it before returning it.
* When something gets sent to the cache every store in the chain gets called to cache the data. Thus everyone in the map is aware of it at the time that is stored.

In most situations one store is all you need, however there are situations where having multiple can be worked to improve performance.
For instance, if you have a memcache server with limited space and a large site (or at least a large cache) you can configure the primary cache to memcache, and the final cache to the default file store cache.
When memcache fills up and is then asked to cache more it drops stored data in order to make space. It has the advantage of being fast, but the disadvantage of limited in size.
By mapping memcache as the primary and file as the secondary you reduce the chances of encounter cache misses because even if memcache has got rid of something to make room for other data what you're looking for may still exist in the file cache.
This would also be useful for a site that was using a memcache server used by other sites/programs/things.

I hope that answers your question, and thank you Tim for bringing this to my attention (really for chasing me up)

Regards
Sam Hemelryk
Average of ratings: Useful (3)
In reply to Sam Hemelryk

Re: Some Cache / MUC questions

by Ron Meske -
Picture of Particularly helpful Moodlers

Thank you Sam!

The documentation is very helpful, it answers/clarifies a few areas I was only guessing at.

One of the areas that would be nice to have more detail on is about sharing caches.  You mention that the language strings are safe to sare between the same versions of Moodle, but it would be nice to know what others are also safe to share.

Perhaps you can also clear up the mystery as to why Memcached is not available to set as a store for Event invalidation.  Unless this is a 2.5.4 issue only.

In reply to Howard Miller

Re: Some Cache / MUC questions

by Ron Meske -
Picture of Particularly helpful Moodlers

Just bumping to see if anyone can help define what the difference between "Primary store" and "Final store" is?

In reply to Ron Meske

Re: Some Cache / MUC questions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Set the primary store, and leave the final store blank. That is what we do at the OU, and I think it is the expected normal case.

I think I know what final store is about, but I am not sure, so I won't say anything because of the risk of spreading misinformation.

Average of ratings: Useful (1)