]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
cache: add number of entries to cache.stats()
authorLukáš Ježek <lukas.jezek@nic.cz>
Fri, 24 Jul 2020 09:00:41 +0000 (11:00 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Thu, 6 Aug 2020 09:35:33 +0000 (11:35 +0200)
NEWS
daemon/bindings/cache.c
daemon/bindings/cache.rst
daemon/lua/kres-gen.lua
lib/cache/cdb_api.h

diff --git a/NEWS b/NEWS
index 1eb4da5d4a0e32f108941d8fb31ce369240b1ff5..0dc56dfdda497801e537ff77f34c5c2bb2f30573 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Improvements
 ------------
 - capabilities are no longer constrained when running as root (!1012)
 - cache: add percentage usage to cache.stats() (!1025)
+- cache: add number of cache entries to cache.stats() (!1028)
 - aarch64 support again, as some systems still didn't work (!1033)
 
 Bugfixes
index d2d37f24b7a0a23b50e37a6b83ba6a910952f1ba..94f8f9b34b1481a64b0dff036e26155cabb6d8e2 100644 (file)
@@ -81,6 +81,8 @@ static int cache_stats(lua_State *L)
        add_stat(open);
        add_stat(close);
        add_stat(count);
+       cache->stats.count_entries = cache->api->count(cache->db, &cache->stats);
+       add_stat(count_entries);
        add_stat(clear);
        add_stat(commit);
        add_stat(read);
index 73f2e089ed99c212bd8c26063894409303ba762f..e295d22432f79ed2b10045f31dc35e269bc7b6a9 100644 (file)
@@ -186,7 +186,7 @@ Configuration reference
 
 .. function:: cache.stats()
 
-   Return table with low-level statistics for each internal cache operation.
+   Return table with low-level statistics for internal cache operation and storage.
    This counts each access to cache and does not directly map to individual
    DNS queries or resource records.
    For query-level statistics see :ref:`stats module <mod-stats>`.
@@ -196,23 +196,27 @@ Configuration reference
    .. code-block:: lua
 
        > cache.stats()
-       [read_leq_miss] => 4
-       [write] => 189
-       [read_leq] => 9
-       [read] => 4313
-       [read_miss] => 1143
-       [open] => 0
+       [clear] => 0
        [close] => 0
-       [remove_miss] => 0
        [commit] => 117
-       [match_miss] => 2
-       [match] => 21
        [count] => 2
-       [clear] => 0
+       [count_entries] => 6187
+       [match] => 21
+       [match_miss] => 2
+       [open] => 0
+       [read] => 4313
+       [read_leq] => 9
+       [read_leq_miss] => 4
+       [read_miss] => 1143
        [remove] => 17
+       [remove_miss] => 0
+       [usage_percent] => 15.625
+       [write] => 189
+
 
    Cache operation `read_leq` (*read less or equal*, i.e. range search) was requested 9 times,
    and 4 out of 9 operations were finished with *cache miss*.
+   Cache contains 6187 internal entries which occupy 15.625 % cache size.
 
 
 .. function:: cache.max_ttl([ttl])
index 8d02db78e23da8aadff684f1c462dae669bb9d41..d22e825272f091020177a681397ffd75df34ccb8 100644 (file)
@@ -199,6 +199,7 @@ struct kr_cdb_stats {
        uint64_t open;
        uint64_t close;
        uint64_t count;
+       uint64_t count_entries;
        uint64_t clear;
        uint64_t commit;
        uint64_t read;
index c04cce533bac3ee3bbb25854b9b1d7c5ec3a0644..9cb784b9c14e14b540d7ef152e62026c5f33a5c0 100644 (file)
@@ -18,6 +18,7 @@ struct kr_cdb_stats {
        uint64_t open;
        uint64_t close;
        uint64_t count;
+       uint64_t count_entries;
        uint64_t clear;
        uint64_t commit;
        uint64_t read;