]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Document putIntoRecordCache and getRecordCacheRecords
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 21 Oct 2024 13:54:53 +0000 (15:54 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 24 Oct 2024 09:23:06 +0000 (11:23 +0200)
pdns/recursordist/docs/lua-scripting/functions.rst

index 404337966ea1ca413795c1eefeb58d13728dd7e7..58f9a49379752cbbb2218400ccd5a40a23edf52f 100644 (file)
@@ -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.