TT#182200 abstract Redis trash/backup table definitions

Use a struct with globally defined instances instead of a literal string
name to distinguish the two destination tables. This makes it possible
to unify record handling between the two tables.

Change-Id: I900debf3a28f262b4503d79562d69b69502b7aa8
(cherry picked from commit d87f661f00)
mr10.4.1
Richard Fuchs 4 years ago
parent 456213a34d
commit 78c774ff3a

@ -44,9 +44,16 @@ typedef struct {
uint64_t index;
} medredis_cidlist_t;
typedef struct {
const char *name;
} medredis_table_t;
static medredis_con_t *con = NULL;
static char medredis_srem_key_lua[41]; // sha-1 hex string
static medredis_table_t medredis_table_trash = { .name = "trash" };
static medredis_table_t medredis_table_backup = { .name = "backup" };
/**********************************************************************/
static void medredis_free_reply(redisReply **reply) {
if (reply && *reply) {
@ -822,10 +829,10 @@ err:
}
/**********************************************************************/
static int medredis_cleanup_entries(med_entry_t *records, uint64_t count, const char *table) {
static int medredis_cleanup_entries(med_entry_t *records, uint64_t count, medredis_table_t *table) {
char buffer[512];
if (medmysql_insert_records(records, count, table) != 0) {
if (medmysql_insert_records(records, count, table->name) != 0) {
L_CRITICAL("Failed to cleanup redis records\n");
goto err;
}
@ -874,10 +881,10 @@ err:
/**********************************************************************/
int medredis_trash_entries(med_entry_t *records, uint64_t count) {
return medredis_cleanup_entries(records, count, "trash");
return medredis_cleanup_entries(records, count, &medredis_table_trash);
}
/**********************************************************************/
int medredis_backup_entries(med_entry_t *records, uint64_t count) {
return medredis_cleanup_entries(records, count, "backup");
return medredis_cleanup_entries(records, count, &medredis_table_backup);
}

Loading…
Cancel
Save