Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

cache.safeRetrieveFirst

Description

This function specifically returns the first matching object from the specified cache alias using the filter conditions as provided. The entire document that has been stored and matches the filter criteria is returned.

If the cache hasn’t been defined in the Cache Pipelines field set, the function returns null.

If the filter criteria doesn’t match any data, it returns null.

Syntax

cache.safeRetrieveFirst("alias", {"filter": "object"})

Examples

Data in cache "data":

Code Block
[
  {"id": 1, "name": "Test", "num": 10},
  {"id": 2, "name": "Test 2", "num": 20},
  {"id": 3, "name": "Test 3", "num": 20}
]

Expressioncache.safeRetrieveFirst("data", {"num": 20})

Result:

Code Block
{"id": 2, "name": "Test 2", "num": 20}

Expression: cache.safeRetrieveFirst("data", {"num": 15})

Result

Code Block
null

Expression: cache.safeRetrieveFirst("data", {"num": 20})

Result:

Code Block
null

...