Memcached is an open source, high-performance, distributed memory object caching system intended for use in speeding up dynamic web applications by alleviating database load.
$ns_key = $memcache->get("foo_namespace_key"); // if not set, initialize it if ($ns_key===false) { $memcache->set("foo_namespace_key", rand(1, 10000)); } // cleverly use the ns_key $my_key = "foo_".$ns_key."_12345"; $my_val = $memcache->get($my_key); // To clear the namespace do: $memcache->increment("foo_namespace_key"); |
If you have a high-traffic site that is dynamically generated with a high database load that contains mostly read threads then memcached can help lighten the load on your database.
Typically, you use a client library from your application to access one or more memcached servers. The Clients page has list of available API libraries, which are available for Perl, C, C#, PHP, Python, Java, Ruby, and Postgresql Stored Procedures and Triggers.