From 7a2d72fe28e29c67f2a9e8fdb59c6c5c9b38d5e6 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 4 Jan 2010 12:49:25 -0500 Subject: Enable memcache automatic compression, starting at 20k and only if compression gain is greater than 20%. Allows storage of larger objects (over 1mb in size uncompressed), such as huge LDAP schemas. Should also improve cache efficiency (allows more stuff to be stored in same memory) and reduce network latency (less data transfer) (redo commit 1e9c03e1993b5d2978ac4c5213a8a64e0150b4a2 which was apparently lost during pluginization) --- plugins/MemcachePlugin.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/MemcachePlugin.php') diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index acbec135e..78e2b2406 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -156,6 +156,11 @@ class MemcachePlugin extends Plugin } $this->_conn->addServer($host, $port); } + //Compress items stored in the cache if they're over 2k in size + //and the compression would save more than 20%. + //Allows the cache to store objects larger than 1MB (if they + //compress to less than 1MB), and improves cache memory efficiency. + $this->_conn->setCompressThreshold(20000, 0.2); } } } -- cgit v1.2.3-54-g00ecf From bcddcb38cebc5ffbffd3df61fb9acaf6f674b133 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 4 Jan 2010 09:09:59 -1000 Subject: make compression threshold and min savings config attrs for MemcachePlugin --- plugins/MemcachePlugin.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'plugins/MemcachePlugin.php') diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index 78e2b2406..998766313 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -54,6 +54,9 @@ class MemcachePlugin extends Plugin private $_conn = null; public $servers = array('127.0.0.1;11211'); + public $compressThreshold = 20480; + public $compressMinSaving = 0.2; + /** * Initialize the plugin * @@ -156,11 +159,16 @@ class MemcachePlugin extends Plugin } $this->_conn->addServer($host, $port); } - //Compress items stored in the cache if they're over 2k in size - //and the compression would save more than 20%. - //Allows the cache to store objects larger than 1MB (if they - //compress to less than 1MB), and improves cache memory efficiency. - $this->_conn->setCompressThreshold(20000, 0.2); + + // Compress items stored in the cache if they're over threshold in size + // (default 2KiB) and the compression would save more than min savings + // ratio (default 0.2). + + // Allows the cache to store objects larger than 1MB (if they + // compress to less than 1MB), and improves cache memory efficiency. + + $this->_conn->setCompressThreshold($this->compressThreshold, + $this->compressMinSaving); } } } -- cgit v1.2.3-54-g00ecf