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
mr10.5.2
Richard Fuchs 4 years ago
parent 64d50ee701
commit d87f661f00

@ -40,9 +40,16 @@ typedef struct {
unsigned int append_counter;
} medredis_con_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) {
@ -802,10 +809,10 @@ err:
}
/**********************************************************************/
static int medredis_cleanup_entries(GQueue *records, const char *table) {
static int medredis_cleanup_entries(GQueue *records, medredis_table_t *table) {
char buffer[512];
if (medmysql_insert_records(records, table) != 0) {
if (medmysql_insert_records(records, table->name) != 0) {
L_CRITICAL("Failed to cleanup redis records\n");
goto err;
}
@ -854,10 +861,10 @@ err:
/**********************************************************************/
int medredis_trash_entries(GQueue *records) {
return medredis_cleanup_entries(records, "trash");
return medredis_cleanup_entries(records, &medredis_table_trash);
}
/**********************************************************************/
int medredis_backup_entries(GQueue *records) {
return medredis_cleanup_entries(records, "backup");
return medredis_cleanup_entries(records, &medredis_table_backup);
}

Loading…
Cancel
Save