execution_repository

Service to interact with execution data stored in Redis cache.

Module Contents

Classes

ExecutionRepository

A repository class to manage execution data in Redis cache.

class execution_repository.ExecutionRepository(redis_cache, mongo_client, execution_collection=__EXECUTION_COLLECTION)

A repository class to manage execution data in Redis cache.

EXECUTION_DATA_TEMPLATE = 'execution_data:{user_name}:{execution_id}'
EXECUTION_ID_TO_USER_INDEX_TEMPLATE = 'execution_id_to_user_mapping:{execution_id}'
USER_TO_EXECUTION_IDS_TEMPLATE = 'user_to_execution_ids_set:{user_name}'
__EXECUTION_COLLECTION
logger
async create_execution_id_to_user_mapping(execution_id, user_name)

Save execution ID to username mapping in inverted index.

async get_execution_model(user_name, execution_id)

Fetch the full execution details dictionary.

async get_latest_execution_ids(user_name, start=0, end=-1)

Get the N latest execution IDs for a user.

async get_latest_execution_models(user_name, start=0, end=-1)

Get the N latest executions for a user. Note: Without a Hash, this performs MGET on full detail strings.

async get_user_name_from_execution_id(execution_id)

Fetch the username associated with a execution ID from the inverted index.

async initialize_execution_data(execution_model)

Save execution model data to Redis cache and update the user’s execution id set. 1. Save the full details as a String with Key: “john:101” 2. Update the Sorted Set index with Key: “users:john:index”, Score: timestamp, Member: execution_id

async save_execution_data(user_name, execution_id, execution_model)

Save only the execution data dictionary.

async save_execution_id_to_user_set(user_name, execution_id, timestamp)

Update only the execution index sorted set.