diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2013-06-11 12:52:10 (GMT) |
---|---|---|
committer | Aleksander Machniak <machniak@kolabsys.com> | 2013-06-21 10:12:15 (GMT) |
commit | 8297464ab4273f5662f1ce47a0c75bf602494e8a (patch) | |
tree | 2c3a760085ec43257e0c155c2f1a1b4d06eaa361 /plugins | |
parent | 9321a10124d1fbba87f8a25114fd583e385c2b66 (diff) | |
download | roundcubemail-plugins-kolab-8297464ab4273f5662f1ce47a0c75bf602494e8a.tar.gz |
Improve performance by reading max_allowed_packet variable (SHOW VARIABLES query) only if needed
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/libkolab/lib/kolab_storage_cache.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index bf0a7dd..e129015 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -35,7 +35,7 @@ class kolab_storage_cache private $synched = false; private $synclock = false; private $ready = false; - private $max_sql_packet = 1046576; // 1 MB - 2000 bytes + private $max_sql_packet; private $max_sync_lock_time = 600; private $binary_cols = array('photo','pgppublickey','pkcs7publickey'); @@ -53,9 +53,6 @@ class kolab_storage_cache if ($this->enabled) { // remove sync-lock on script termination $rcmail->add_shutdown_function(array($this, '_sync_unlock')); - - // read max_allowed_packet from mysql config - $this->max_sql_packet = min($this->db->get_variable('max_allowed_packet', 1048500), 4*1024*1024) - 2000; // mysql limit or max 4 MB } if ($storage_folder) @@ -630,7 +627,7 @@ class kolab_storage_cache $line = '(' . join(',', $values) . ')'; } - if ($buffer && (!$msguid || (strlen($buffer) + strlen($line) > $this->max_sql_packet))) { + if ($buffer && (!$msguid || (strlen($buffer) + strlen($line) > $this->max_sql_packet()))) { $result = $this->db->query( "INSERT INTO kolab_cache ". " (resource, type, msguid, uid, created, changed, data, xml, dtstart, dtend, tags, words)". @@ -650,6 +647,20 @@ class kolab_storage_cache } /** + * Returns max_allowed_packet from mysql config + */ + private function max_sql_packet() + { + if (!$this->max_sql_packet) { + // mysql limit or max 4 MB + $value = $this->db->get_variable('max_allowed_packet', 1048500); + $this->max_sql_packet = min($value, 4*1024*1024) - 2000; + } + + return $this->max_sql_packet; + } + + /** * Check lock record for this folder and wait if locked or set lock */ private function _sync_lock() |