<<

NAME

ProductOpener::Redis - functions to integrate with redis

DESCRIPTION

ProductOpener::Redis is handling pushing info to Redis to communicate updates to all services, including search-a-licious, as well as receiving updates from other services like Keycloak.

$redis_client

The connection to redis

init_redis($is_reconnect=0)

init $redis_client or re-init it if we where disconnected

it is uses ProductOpener::Config2::redis_url

subscribe_to_redis_streams ()

Subscribe to redis stream to be informed about user deletions.

push_product_update_to_redis ($product_ref, $change_ref, $action)

Add an event to Redis stream to inform that a product was updated.

Arguments

Product Object $product_ref

The product that was updated.

HashRef $change_ref

The changes, structured as per product change history

String $action

The action that was performed on the product (either "updated" or "deleted"). A product creation is considered as an update.

push_ocr_ready_to_redis ($code, $image_id)

Add an event to Redis stream to notify that OCR was run on an image and that the OCR result (gzipped JSON file) is ready to be used.

Arguments

String $code

The product code associated with the image.

String $image_id

The ID of the image.

String $json_url

The URL where the OCR result JSON file can be found.

get_rate_limit_user_requests ($ip, $bucket)

Return the number of requests performed by the given user for the current minute for the given rate-limit bucket. See https://redis.com/glossary/rate-limiting/ for more information.

If the rate-limiter is not configured or if an error occurs, returns undef.

Arguments

String $ip

The IP address of the user who is making the request.

String $bucket

The rate-limit bucket that is being requested.

increment_rate_limit_requests ($ip, $bucket)

Increment the number of requests according to the Redis rate-limiter for the current minute for the given user and bucket. The expiration of the counter is set to 59 seconds. See https://redis.com/glossary/rate-limiting/ for more information.

Arguments

String $ip

The IP address of the user who is making the request.

String $bucket

The rate-limit bucket that is being requested.

<<