You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This patch adds a time-to-live (TTL) option to `config.storage` API
methods. This option allows one to put keys that will expire when the
passed time passes.
Closestarantool/enterprise_doc#281
Copy file name to clipboardExpand all lines: doc/reference/reference_lua/config.rst
+67-2Lines changed: 67 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -395,12 +395,16 @@ The ``config.storage`` API allows you to interact with a Tarantool-based :ref:`c
395
395
396
396
.. _config_storage_api_reference_put:
397
397
398
-
.. function:: put(path, value)
398
+
.. function:: put(path, value, opts)
399
399
400
400
Put a value by the specified path.
401
401
402
402
:param string path: a path to put the value by
403
403
:param string value: a value to put
404
+
:param table opts: a table containing the following optional fields:
405
+
406
+
* ``ttl`` (since :doc:`3.2.0 </release/3.2.0>`, default: unset): time-to-live in seconds, if nil or not set the key won't expire, may issue an error if set on config.storage running old schema, see :ref:`config.storage.info <config_storage_api_reference_info>`.
407
+
404
408
405
409
:return: a table containing the following fields:
406
410
@@ -516,9 +520,25 @@ The ``config.storage`` API allows you to interact with a Tarantool-based :ref:`c
516
520
* ``connected``: if any instance from the quorum is available to the current instance
517
521
* ``disconnected``: if the current instance doesn't have a connection with the quorum
518
522
523
+
* ``features`` (since :doc:`3.2.0 </release/3.2.0>`): a table of features config.storage supports, may include the following:
524
+
525
+
* ``ttl``: true if key TTL (time-to-live) is supported, false otherwise if the schema hasn't been upgraded yet
526
+
527
+
519
528
:rtype: table
520
529
521
530
531
+
**Example:**
532
+
533
+
The example below shows how to check whether config.storage supports keys TTL:
534
+
535
+
.. code-block:: lua
536
+
537
+
local info = config.storage.info
538
+
if info.features == nil or not info.features.ttl then
539
+
error('...')
540
+
end
541
+
522
542
.. _config_storage_api_reference_txn:
523
543
524
544
.. function:: txn(request)
@@ -542,6 +562,17 @@ The ``config.storage`` API allows you to interact with a Tarantool-based :ref:`c
542
562
543
563
* ``on_failure``: a list with operations to execute if any of a predicate evaluates to ``false``
544
564
565
+
Operations in ``on_success`` and ``on_failure`` follow the format:
566
+
567
+
.. code-block:: none
568
+
569
+
{operation, key_or_path[, value][, opts]}
570
+
571
+
* ``operation``: one of ``'put'``, ``'get'``, ``'delete'``
572
+
* ``opts``: a table containing optional fields for the operations:
573
+
574
+
* ``ttl`` (since :doc:`3.2.0 </release/3.2.0>`, default: unset): time-to-live for a key in seconds, if nil or not set the key won't expire
575
+
545
576
:return: a table containing the following fields:
546
577
547
578
* ``data``: a table containing response data:
@@ -608,12 +639,17 @@ Examples on GitHub: `config_storage <https://github.com/tarantool/doc/tree/lates
Put a value by the specified path to remote config.storage.
614
645
615
646
:param string path: a path to put the value by
616
647
:param string value: a value to put
648
+
:param table opts: a table containing the following optional fields:
649
+
650
+
* ``ttl`` (since :doc:`3.2.0 </release/3.2.0>`, default: unset): time-to-live in seconds, if nil or not set the key won't expire, may issue an error if set on config.storage running old schema, see :ref:`<config.storage client>.info <config_storage_client_api_reference_info>`.
651
+
652
+
617
653
618
654
:return: a table containing the following fields:
619
655
@@ -727,9 +763,26 @@ Get information about a connection state to the config.storage cluster.
727
763
* ``connected``: if any instance from the quorum is available to the current instance
728
764
* ``disconnected``: if the current instance doesn't have a connection with the quorum
729
765
766
+
* ``features`` (since :doc:`3.2.0 </release/3.2.0>`): a table of features config.storage supports, may include the following:
767
+
768
+
* ``ttl``: true if key TTL (time-to-live) is supported, false otherwise if the schema hasn't been upgraded yet
769
+
770
+
730
771
:rtype: table
731
772
732
773
774
+
**Example:**
775
+
776
+
The example below shows how to check whether remote config.storage supports keys TTL:
777
+
778
+
.. code-block:: lua
779
+
780
+
local info = storage_client.info
781
+
if info.features == nil or not info.features.ttl then
0 commit comments