From aba7887d4e3d9e91227c15c06674c887eabe6388 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 21 Oct 2024 15:54:53 +0200 Subject: [PATCH] Document putIntoRecordCache and getRecordCacheRecords --- .../docs/lua-scripting/functions.rst | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pdns/recursordist/docs/lua-scripting/functions.rst b/pdns/recursordist/docs/lua-scripting/functions.rst index 404337966e..58f9a49379 100644 --- a/pdns/recursordist/docs/lua-scripting/functions.rst +++ b/pdns/recursordist/docs/lua-scripting/functions.rst @@ -29,3 +29,31 @@ These are some functions that don't really have a place in one of the other cate Spawn a thread. :param str script: The pathname of the Lua script to run. + +.. function:: putIntoRecordCache(dump) -> int + + .. versionadded:: 5.2.0 + + Put a record cache dump into the record cache. + + :param str dump: The data in the proprietary format produced by :func:`getRecordCacheRecords`). + :returns: The number of records inserted into the record cache. + + Some records might be skipped, for example when they are already present in the record cache or contain specific information not supported yet by this function. + If the :program:`Recursor` determines the version of the data is not compatible, it will skip loading and log an error. + +.. function:: getRecordCacheRecords(perShard, maxSize) ->str + + .. versionadded:: 5.2.0 + + Get a record cache dump in proprietary format. + + :param int perShard: The maximum number of records to produce per shard. + :param int maxSize: The maximum size of the dump. + + :return: A string representing the records. + + This function will scan the most recently used records of each shard, picking at most ``perShard`` records per shard and adding them to the result. + If adding a record's data to the result would make the result size exceed ``maxSize``, the remainder of the current shard and further remaining shards are skipped. + The format of the string produced is proprietary. + The string contains meta information, so the :program:`Recursor` calling :func:`putIntoRecordCache` can check if the data format is compatible. -- 2.47.3