Comparison

plugins/mod_storage_sql.lua @ 9893:15270547c91c

mod_storage_sql: Return cached count if only this is queried for
author Kim Alvefur <zash@zash.se>
date Fri, 22 Mar 2019 02:18:54 +0100
parent 9892:4803a25c7e36
child 9896:dafe1b544822
comparison
equal deleted inserted replaced
9892:4803a25c7e36 9893:15270547c91c
360 end 360 end
361 361
362 function archive_store:find(username, query) 362 function archive_store:find(username, query)
363 query = query or {}; 363 query = query or {};
364 local user,store = username,self.store; 364 local user,store = username,self.store;
365 local total; 365 local cache_key = jid_join(username, host, self.store);
366 local total = archive_item_count_cache:get(cache_key);
367 if total ~= nil and query.limit == 0 and query.start == nil and query.with == nil and query["end"] == nil and query.key == nil then
368 return noop, total;
369 end
366 local ok, result = engine:transaction(function() 370 local ok, result = engine:transaction(function()
367 local sql_query = [[ 371 local sql_query = [[
368 SELECT "key", "type", "value", "when", "with" 372 SELECT "key", "type", "value", "when", "with"
369 FROM "prosodyarchive" 373 FROM "prosodyarchive"
370 WHERE %s 374 WHERE %s