Skip to content

Commit

Permalink
Updated the query cache overview document
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://kelev.kaltura.com/usr/local/kalsource/backend/server/trunk/core@62285 6b8eccd3-e8c5-4e7d-8186-e12b5326b719
  • Loading branch information
erank committed May 15, 2011
1 parent e8b3ce6 commit d93837c
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions doc/Query Cache Overview.htm
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ <h3>When do we update the invalidation keys ?</h3>
Whenever a flavor asset object of entry_id x is saved, it will also update the time saved in the memcache
under 'flavor_asset:entry_id=x', thus invalidating all the queries that contained entry_id=x.
On single datacenter environments the invalidation keys can be updated automatically by the 'save'
functions. On multi datacenter environments this won't work because it won't invalidate the queries
that are cached on the remote DC. So, instead, we'll define UDFs (User Defined Functions) on the
database that will perform the invalidation - whether the database was modified locally or by the
replication.
functions. On multi datacenter environments this won't work, because it won't invalidate the queries
that are cached on the remote DC. So, instead, we'll define triggers on the database that will perform
the invalidation - whether the database was modified locally or by the replication.
</p>
<h3>What's needed to add a new query to the cache ?</h3>
<p>
Expand All @@ -54,8 +53,31 @@ <h3>What's needed to add a new query to the cache ?</h3>
$this object is saved.
<li>&lt;peer&gt;::getCacheInvalidationKeys – returns a list of invalidation keys that should be checked before
the supplied $criteria can be returned from the cache.
</ul>
See asset.php & assetPeer.php as an example.
</p>
<h3>What is the process for setting up the query cache ?</h3>
<p>
<h4>All environments</h4>
Set up a single machine on each datacenter that will run the shared memcached. Configure the hostname and port
of this memcache in kConfLocal (global_memcache_host / global_memcache_port).
<h4>Single datacenter environment only</h4>
On all servers, set query_cache_enabled and query_cache_invalidate_on_change to true in kConfLocal
<h4>Multi datacenter environment only</h4>
Perform the following on one of the mysql slaves in each datacenter:
<ul>
<li>Compile and install 'Memcached Functions for MySQL'. To install a precompiled version:
<ul>
<li>Copy /usr/lib64/mysql/plugin/libmemcached_functions_mysql.so and /usr/local/lib64/libmemcached.so.
<li>Install the functions by running: mysql kaltura &lt; memcached_functions_mysql-1.0/sql/install_functions.sql
</ul>
<li>Configure the 'Memcached Functions for MySQL' library to use the shared memcache server by adding the
command 'select memc_servers_set('&lt;global memcache host&gt;:&lt;global memcache port&gt;');' to the mysql init script.<br>
<b>Note:</b> To add an init script for mysql, add the command line switch '--init-file=&lt;mysql init script path&gt;' to mysqld.
<li>Restart mysql.
<li>Install the triggers by running from deployment/base/scripts: php query_cache_triggers.php create &lt;host&gt; &lt;user&gt; &lt;password&gt;
</ul>
On all servers, set query_cache_enabled to true in kConfLocal (query_cache_invalidate_on_change should be left false).
</p>
</body>
</html>
</html>

0 comments on commit d93837c

Please sign in to comment.