- Added methods `enqueueInvoicePeriodWarming` and `consumeInvoicePeriodWarmingQueue` to the `Redis` interface for managing warming periods. - Modified `invoice_period_flag_service` to enqueue warming periods on cache misses. - Updated cron job logic to process invoice period warming queues and ensure flags are warmed effectively.
398 lines
10 KiB
PHP
398 lines
10 KiB
PHP
<?php
|
|
|
|
namespace interfaces;
|
|
|
|
interface redis_i
|
|
{
|
|
/**
|
|
* Cache a departments booking count (cached)
|
|
* @param int $department_id
|
|
* @param int $count
|
|
* @return self
|
|
*/
|
|
public function cache_department_booking_count(int $department_id, int $count): self;
|
|
|
|
/**
|
|
* Get a departments booking count (cached)
|
|
* @param int $department_id
|
|
* @return int|null
|
|
*/
|
|
public function get_department_booking_count(int $department_id): int|null;
|
|
|
|
/**
|
|
* Clear a departments booking count (cached)
|
|
* @param int $department_id
|
|
* @return self
|
|
*/
|
|
public function clear_department_booking_count(int $department_id): self;
|
|
|
|
|
|
/**
|
|
* Cache a department webhook
|
|
* @param int $department_id
|
|
* @param string $webhook
|
|
* @return self
|
|
*/
|
|
public function cache_department_webhook(int $department_id, string $webhook): self;
|
|
|
|
/**
|
|
* Get a department webhook
|
|
* @param int $department_id
|
|
* @return string|null
|
|
*/
|
|
public function get_department_webhook(int $department_id): string|null;
|
|
|
|
/**
|
|
* Clear a department webhook
|
|
* @param int $department_id
|
|
* @return self
|
|
*/
|
|
public function clear_department_webhook(int $department_id): self;
|
|
|
|
/**
|
|
* Cache a department name
|
|
* @param int $department_id
|
|
* @param string $department_name
|
|
* @return self
|
|
*/
|
|
public function cache_department_name(int $department_id, string $department_name): self;
|
|
|
|
/**
|
|
* Get a department name
|
|
* @param int $department_id
|
|
* @return string|null
|
|
*/
|
|
public function get_department_name(int $department_id): string|null;
|
|
|
|
/**
|
|
* Clear a department name
|
|
* @param int $department_id
|
|
* @return self
|
|
*/
|
|
public function clear_department_name(int $department_id): self;
|
|
|
|
/**
|
|
* Cache an economic customers discount percentage
|
|
* @param int $user_id
|
|
* @param int $discount_percentage
|
|
* @return self
|
|
*/
|
|
public function cache_economic_customer_discount_percentage(int $user_id, int $discount_percentage): self;
|
|
|
|
/**
|
|
* Get an economic customers discount percentage
|
|
* @param int $user_id
|
|
* @return int|null
|
|
*/
|
|
public function get_economic_customer_discount_percentage(int $user_id): int|null;
|
|
|
|
/**
|
|
* Clear an economic customers discount percentage
|
|
* @param int $user_id
|
|
* @return self
|
|
*/
|
|
public function clear_economic_customer_discount_percentage(int $user_id): self;
|
|
|
|
/**
|
|
* Cache a customer notes
|
|
* @param int $user_id
|
|
* @param array $customer_notes
|
|
* @return self
|
|
*/
|
|
public function cache_customer_notes(int $user_id, array $customer_notes): self;
|
|
|
|
/**
|
|
* Get a customer notes
|
|
* @param int $user_id
|
|
* @return array|null
|
|
*/
|
|
public function get_customer_notes(int $user_id): array|null;
|
|
|
|
/**
|
|
* Clear a customer notes
|
|
* @param int $user_id
|
|
* @return self
|
|
*/
|
|
public function clear_customer_notes(int $user_id): self;
|
|
|
|
/**
|
|
* Add a log to the logs cache
|
|
* @param string $module
|
|
* @param string $department
|
|
* @param int $type
|
|
* @param int $user_id
|
|
* @param string $action
|
|
* @param string $message
|
|
* @return self
|
|
*/
|
|
public function add_log(string $module, string $department, int $type, int $user_id, string $action, string $message): self;
|
|
|
|
/**
|
|
* Get all logs from the logs cache
|
|
* @return array|null
|
|
*/
|
|
public function get_logs(): array|null;
|
|
|
|
/**
|
|
* Clear all logs from the logs cache
|
|
* @return self
|
|
*/
|
|
public function clear_logs(): self;
|
|
|
|
/**
|
|
* Cache a department
|
|
* @param int $department_id
|
|
* @param array $department
|
|
* @return self
|
|
*/
|
|
public function cache_department(int $department_id, array $department): self;
|
|
|
|
/**
|
|
* Get a department
|
|
* @param int $department_id
|
|
* @return array|null
|
|
*/
|
|
public function get_department(int $department_id): array|null;
|
|
|
|
/**
|
|
* Clear a department
|
|
* @param int $department_id
|
|
* @return self
|
|
*/
|
|
public function clear_department(int $department_id): self;
|
|
|
|
/**
|
|
* Get departments from the cache
|
|
* @return array|null
|
|
*/
|
|
public function get_departments(): array|null;
|
|
|
|
/**
|
|
* Cache departments
|
|
* @param array $departments
|
|
* @return self
|
|
*/
|
|
public function cache_departments(array $departments): self;
|
|
|
|
/**
|
|
* Clear departments from the cache
|
|
* @return self
|
|
*/
|
|
public function clear_departments(): self;
|
|
|
|
/**
|
|
* Get the log count
|
|
* @return int
|
|
*/
|
|
public function get_log_count(): int;
|
|
|
|
/**
|
|
* Cache a token
|
|
* @param string $token
|
|
* @param array $row
|
|
* @return self
|
|
*/
|
|
public function cache_token(string $token, array $row): self;
|
|
|
|
/**
|
|
* Get a token
|
|
* @param string $token
|
|
* @return array|null
|
|
*/
|
|
public function get_token(string $token): array|null;
|
|
|
|
/**
|
|
* Delete a token
|
|
* @param string $token
|
|
* @return self
|
|
*/
|
|
public function clear_token(string $token): self;
|
|
|
|
/**
|
|
* Get the last cron task
|
|
* @param string $task
|
|
* @return int|null
|
|
*/
|
|
public function get_last_crond_run(string $task): int|null;
|
|
|
|
/**
|
|
* Set the last cron task
|
|
* @param string $task
|
|
* @param int $time
|
|
* @return self
|
|
*/
|
|
public function set_last_crond_run(string $task, int $time): self;
|
|
|
|
/**
|
|
* Get a users id from customer number from the cache
|
|
* @param int $customer_number
|
|
* @return int|null
|
|
*/
|
|
public function get_user_id_from_customer_number(int $customer_number): int|null;
|
|
|
|
/**
|
|
* Cache a users id from customer number
|
|
* @param int $customer_number
|
|
* @param int $user_id
|
|
* @return self
|
|
*/
|
|
public function cache_user_id_from_customer_number(int $customer_number, int $user_id): self;
|
|
|
|
/**
|
|
* Clear a users id from customer number from the cache
|
|
* @param int $customer_number
|
|
* @return self
|
|
*/
|
|
public function clear_user_id_from_customer_number(int $customer_number): self;
|
|
|
|
/**
|
|
* Get a customer number from user id from the cache
|
|
* @param int $user_id
|
|
* @return int|null
|
|
*/
|
|
public function get_customer_number_from_user_id(int $user_id): int|null;
|
|
|
|
/**
|
|
* Cache a customer number from user id
|
|
* @param int $user_id
|
|
* @param int $customer_number
|
|
* @return self
|
|
*/
|
|
public function cache_customer_number_from_user_id(int $user_id, int $customer_number): self;
|
|
|
|
/**
|
|
* Clear a customer number from user id from the cache
|
|
* @param int $user_id
|
|
* @return self
|
|
*/
|
|
public function clear_customer_number_from_user_id(int $user_id): self;
|
|
|
|
/**
|
|
* Cache an auth session payload for a given token
|
|
* @param string $token
|
|
* @param array $session
|
|
* @param int $ttl Seconds to keep in cache
|
|
* @return self
|
|
*/
|
|
public function cache_auth_session(string $token, array $session, int $ttl = 60): self;
|
|
|
|
/**
|
|
* Get a cached auth session payload by token
|
|
* @param string $token
|
|
* @return array|null
|
|
*/
|
|
public function get_auth_session(string $token): array|null;
|
|
|
|
/**
|
|
* Clear a cached auth session payload by token
|
|
* @param string $token
|
|
* @return self
|
|
*/
|
|
public function clear_auth_session(string $token): self;
|
|
|
|
/**
|
|
* Cache invoice period manual flags payload
|
|
* @param array $flags
|
|
* @return self
|
|
*/
|
|
public function cache_invoice_period_manual_flags(array $flags): self;
|
|
|
|
/**
|
|
* Get cached invoice period manual flags payload
|
|
* @return array|null
|
|
*/
|
|
public function get_invoice_period_manual_flags(): array|null;
|
|
|
|
/**
|
|
* Clear cached invoice period manual flags payload
|
|
* @return self
|
|
*/
|
|
public function clear_invoice_period_manual_flags(): self;
|
|
|
|
/**
|
|
* Cache invoice period automatic flags payload for a date range
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @param array $flags
|
|
* @return self
|
|
*/
|
|
public function cache_invoice_period_automatic_flags(string $dateFrom, string $dateTo, array $flags): self;
|
|
|
|
/**
|
|
* Get cached invoice period automatic flags payload for a date range
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @return array|null
|
|
*/
|
|
public function get_invoice_period_automatic_flags(string $dateFrom, string $dateTo): array|null;
|
|
|
|
/**
|
|
* Clear cached invoice period automatic flags payload for a date range
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @return self
|
|
*/
|
|
public function clear_invoice_period_automatic_flags(string $dateFrom, string $dateTo): self;
|
|
|
|
/**
|
|
* Cache invoice period order item rows for a date range
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @param array $rows
|
|
* @return self
|
|
*/
|
|
public function cache_invoice_period_order_item_rows(string $dateFrom, string $dateTo, array $rows): self;
|
|
|
|
/**
|
|
* Get cached invoice period order item rows for a date range
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @return array|null
|
|
*/
|
|
public function get_invoice_period_order_item_rows(string $dateFrom, string $dateTo): array|null;
|
|
|
|
/**
|
|
* Clear cached invoice period order item rows for a date range
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @return self
|
|
*/
|
|
public function clear_invoice_period_order_item_rows(string $dateFrom, string $dateTo): self;
|
|
|
|
/**
|
|
* Cache a permission evaluation
|
|
* @param string $cache_key
|
|
* @param bool $allowed
|
|
* @param int $ttl
|
|
* @return self
|
|
*/
|
|
public function cache_permission(string $cache_key, bool $allowed, int $ttl = 300): self;
|
|
|
|
/**
|
|
* Get a cached permission evaluation
|
|
* @param string $cache_key
|
|
* @return bool|null
|
|
*/
|
|
public function get_permission(string $cache_key): bool|null;
|
|
|
|
/**
|
|
* Clear a cached permission evaluation
|
|
* @param string $cache_key
|
|
* @return self
|
|
*/
|
|
public function clear_permission(string $cache_key): self;
|
|
|
|
/**
|
|
* Enqueue a period for automatic flags warming.
|
|
* @param string $dateFrom
|
|
* @param string $dateTo
|
|
* @return self
|
|
*/
|
|
public function enqueue_invoice_period_warming(string $dateFrom, string $dateTo): self;
|
|
|
|
/**
|
|
* Consume all queued warming periods and clear the queue.
|
|
* @return array<int,array{dateFrom:string,dateTo:string}>
|
|
*/
|
|
public function consume_invoice_period_warming_queue(): array;
|
|
} |