ReadFromCache

Step reads data from cache using save_key, sets the returned data for next step.

Added in version 1.0.0.

  • Friendly name: Cache Read

  • Step class: base_steps_syncpack.steps.ReadFromCache.ReadFromCache

  • Step version: 1.4.0

  • Required parameters: save_key, lookup_type

Parameters

Name

Type

Required

Default

Description

save_key

string

yes

–

The key with which to read from the cache Example: keyA

lookup_type

enum

yes

like

How to perform the search from cache. Can either be ‘equals’, or ‘like’

merge_results

boolean

no

True

Try to combine the results into a single list

default_value

string

no

–

Value to return if None Example: True

Every step also accepts the platform parameters common to all steps – see Platform parameters.

Dependencies

  • Inherits from: ReadFromCache -> BaseStep -> Serializable

  • External packages: couchbase, ipaascommon, ipaascore, isbaseutils

Behaviour

Reads one or more cache entries and passes them downstream. lookup_type selects how save_key is matched:

equals

Exact key match.

like

Prefix or pattern match. Keys are resolved with get_ids_from_logs_bucket_startswith, falling back to an N1QL META().id LIKE query (INT-6201). This is what reassembles the key::1, key::2 chunks written by SaveToCache.

Outputs

The retrieved data:

  • merge_results true (the default) — all matches merged into one structure;

  • merge_results false — a list with one entry per matching key.

When nothing matches, the output is default_value if one is set, otherwise an empty list [].

Example

{
  "save_key": "snow-open-incidents",
  "lookup_type": "like",
  "merge_results": true
}

Notes

  • A miss is not an error. The step saves [] and the workflow continues, so a downstream step has to handle the empty case — a typo in save_key looks exactly like an empty cache.

  • Use like for anything written by SaveToCache that might have been chunked. With equals you get only the un-suffixed base document, which for chunked data is not the full set.

  • merge_results changes the output shape. Flipping it breaks downstream steps written against the other form.

API

class base_steps_syncpack.steps.ReadFromCache.ReadFromCache

Bases: BaseStep

execute()

All logic main logic for executing the step happens here

Returns:

get_id_list(lookup_type)

Return the list of keys associated with the cache entries we need to retrieve

Parameters:

lookup_type (str) – see step parameter

Returns:

get_cache_data_with_keys(id_list)

Return a list of teh contents for each id queried

Parameters:

id_list (list) – ids to query for

Returns list: