Software /
code /
prosody
Changeset
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 |
parents | 9892:4803a25c7e36 |
children | 9894:8747ccf0008c |
files | plugins/mod_storage_sql.lua |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Fri Mar 22 02:13:27 2019 +0100 +++ b/plugins/mod_storage_sql.lua Fri Mar 22 02:18:54 2019 +0100 @@ -362,7 +362,11 @@ function archive_store:find(username, query) query = query or {}; local user,store = username,self.store; - local total; + local cache_key = jid_join(username, host, self.store); + local total = archive_item_count_cache:get(cache_key); + if total ~= nil and query.limit == 0 and query.start == nil and query.with == nil and query["end"] == nil and query.key == nil then + return noop, total; + end local ok, result = engine:transaction(function() local sql_query = [[ SELECT "key", "type", "value", "when", "with"