Open main menu

Changes

m
Fix flush all command syntax
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. See the [https://github.com/memcached/memcached/wiki/TutorialCachingStory Caching Story] that explains how every web application eventually turns to caching to increase performance.
== Memcached commands ==Dump all the keys in memcached<syntaxhighlight lang="bash">memdump --servers=localhost</syntaxhighlight> simpleSAMLphp.session.5c88998d9c84839323e37f563ba75fbd GET a specific key value<syntaxhighlight lang="bash">echo 'get simpleSAMLphp.session.5c88998d9c84839323e37f563ba75fbd' | nc 127.0.0.1 11211</syntaxhighlight> VALUE simpleSAMLphp.session.5c88998d9c84839323e37f563ba75fbd 0 1879 a:2:{s:9:"timestamp";d:1711046755.552315;s:4:"data";O:18:"SimpleSAML\Session":10:{s:9:"sessionId";s:32:"5c88998d9c84839323e37f563ba75fbd";s:9:"transient";b:0;s:7:"trackid";s:10:"6db0c2e647";s:16:"rememberMeExpire";N;s:5:"dirty";b:0;s:19:"callback_registered";b:0;s:9:"dataStore";a:1:{s:16:"core:errorreport";a:3:{s:8:"509a5645";a:3:{s:7:"expires";i:1711061090;s:7:"timeout";i:14400;s:4:"data";a:7:{s:12:"exceptionMsg";s:174:"SimpleSAML\Error\NotFound: The requested page 'https://localhost/simplesaml/module.php/admin/' could not be found. The module 'admin' was either not found, or wasn't enabled.";s:14:"exceptionTrace";s:0:"";s:8:"reportId";s:8:"509a5645";s:7:"trackId";s:10:"6db0c2e647";s:3:"url";s:46:"https://localhost/simplesaml/module.php/admin/";s:7:"version";s:5:"2.1.1";s:7:"referer";s:7:"unknown";}}s:8:"6f3f88ff";a:3:{s:7:"expires";i:1711061101;s:7:"timeout";i:14400;s:4:"data";a:7:{s:12:"exceptionMsg";s:174:"SimpleSAML\Error\NotFound: The requested page 'https://localhost/simplesaml/module.php/admin/' could not be found. The module 'admin' was either not found, or wasn't enabled.";s:14:"exceptionTrace";s:0:"";s:8:"reportId";s:8:"6f3f88ff";s:7:"trackId";s:10:"6db0c2e647";s:3:"url";s:46:"https://localhost/simplesaml/module.php/admin/";s:7:"version";s:5:"2.1.1";s:7:"referer";s:7:"unknown";}}s:8:"ccb23c67";a:3:{s:7:"expires";i:1711061155;s:7:"timeout";i:14400;s:4:"data";a:7:{s:12:"exceptionMsg";s:174:"SimpleSAML\Error\NotFound: The requested page 'https://localhost/simplesaml/module.php/admin/' could not be found. The module 'admin' was either not found, or wasn't enabled.";s:14:"exceptionTrace";s:0:"";s:8:"reportId";s:8:"ccb23c67";s:7:"trackId";s:10:"6db0c2e647";s:3:"url";s:46:"https://localhost/simplesaml/module.php/admin/";s:7:"version";s:5:"2.1.1";s:7:"referer";s:7:"unknown";}}}}s:12:"associations";a:0:{}s:9:"authToken";N;s:8:"authData";a:0:{}}} END Empty the memcached (it doesn't actually delete, but it expires everything)<syntaxhighlight lang="bash">echo 'flush_all' | nc 127.0.0.1 11211</syntaxhighlight>  ==See Also:==
*[https://github.com/memcached/memcached/wiki/Commands Memcache Commands]
*MediaWiki has a diagnostic tool for interacting with memcached in the 'maintenance' directory: [https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/maintenance/mcc.php mcc.php]
*[https://stackoverflow.com/questions/8420776/how-do-i-view-the-data-in-memcache Viewing data in memcache]
 
Try <syntaxhighlight lang="bash">echo stats | nc 127.0.0.1 11211</syntaxhighlight>
<blockquote>"Cache is King" - borrowed from the aphorism "Cash is King" For a full exploration of object caching in MediaWiki see https://www.mediawiki.org/wiki/Object_cache </blockquote>
If you are a MediaWiki developer - especially a front-end dev, you've probably seen references in code to the 'BagOStuff' and wondered "what the heck is it?" BagOStuff is an abstract Class representing a cache/ephemeral data store. Concrete classes then build upon or implement BagOStuff in ways that are compatible with those concrete storage mechanisms. <ref>https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/includes/libs/objectcache/BagOStuff.php</ref> WANCache builds on top of '''BagOStuff''', which is the lower level key-value interface to Memcached and other storage backends.
{{References}}
[[File:Wikipedia_Memcached_flow_2022.png|alt=illustration of Memcached flow from MediaWiki|right|955x955px|Memcached flow from MediaWiki]]
<br />{{References}}
[[Category:Caching]]
[[Category:Performance]]
<references />