Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 916b37b

Browse files
committed
rename type of a database (connection)
1 parent 3aa2f7c commit 916b37b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

rediSQL.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828

2929
#define PERSISTENTSQLITEDB_ENCODING_VERSION 1
3030

31-
static RedisModuleType *PersistentSQLiteDB;
31+
static RedisModuleType *RediSQL_SQLiteDB;
3232

3333
typedef struct {
3434
char *name;
3535
sqlite3 *connection;
36-
} PhyPersistentSQLiteDB;
36+
} Phy_RediSQL_SQLiteDB;
3737

3838
sqlite3 *db;
3939

@@ -75,7 +75,7 @@ int createDB(RedisModuleCtx *ctx, RedisModuleString *key_name, const char *path)
7575
return RedisModule_ReplyWithError(ctx, "KEY_USED The key used is already bind");
7676
}
7777

78-
PhyPersistentSQLiteDB *PhySQLiteDB = RedisModule_Alloc(sizeof(PhyPersistentSQLiteDB));
78+
Phy_RediSQL_SQLiteDB *PhySQLiteDB = RedisModule_Alloc(sizeof(Phy_RediSQL_SQLiteDB));
7979
PhySQLiteDB->name = RedisModule_Alloc(sizeof(char) * 100);
8080
if (NULL == path){
8181
PhySQLiteDB->name = NULL;
@@ -92,7 +92,7 @@ int createDB(RedisModuleCtx *ctx, RedisModuleString *key_name, const char *path)
9292

9393
RedisModule_CloseKey(key);
9494
if (REDISMODULE_OK == RedisModule_ModuleTypeSetValue(
95-
key, PersistentSQLiteDB, PhySQLiteDB)){
95+
key, RediSQL_SQLiteDB, PhySQLiteDB)){
9696
return RedisModule_ReplyWithSimpleString(ctx, "OK");
9797
} else {
9898
return RedisModule_ReplyWithError(ctx, "ERR - Impossible to set the key");
@@ -122,7 +122,7 @@ int DeleteDB(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
122122
return RedisModule_ReplyWithError(ctx, "KEY_EMPTY The key used is empty");
123123
}
124124

125-
if (PersistentSQLiteDB != RedisModule_ModuleTypeGetType(key)){
125+
if (RediSQL_SQLiteDB != RedisModule_ModuleTypeGetType(key)){
126126
RedisModule_CloseKey(key);
127127
return RedisModule_ReplyWithError(ctx, REDISMODULE_ERRORMSG_WRONGTYPE);
128128
}
@@ -140,7 +140,7 @@ int ExecCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
140140
const char* query;
141141
RedisModuleKey *key;
142142
int key_type;
143-
PhyPersistentSQLiteDB *key_value;
143+
Phy_RediSQL_SQLiteDB *key_value;
144144

145145
if (3 != argc){
146146
return RedisModule_WrongArity(ctx);
@@ -150,7 +150,7 @@ int ExecCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
150150
key_type = RedisModule_KeyType(key);
151151

152152
if (REDISMODULE_KEYTYPE_EMPTY == key_type ||
153-
RedisModule_ModuleTypeGetType(key) != PersistentSQLiteDB ){
153+
RedisModule_ModuleTypeGetType(key) != RediSQL_SQLiteDB ){
154154

155155
return RedisModule_ReplyWithError(ctx, REDISMODULE_ERRORMSG_WRONGTYPE);
156156
}
@@ -258,7 +258,7 @@ int SQLiteVersion(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
258258
}
259259

260260
void FreePhySQLiteDB(void *PSQLiteDB){
261-
PhyPersistentSQLiteDB *PhySQLiteDB = (PhyPersistentSQLiteDB*)PSQLiteDB;
261+
Phy_RediSQL_SQLiteDB *PhySQLiteDB = (Phy_RediSQL_SQLiteDB*)PSQLiteDB;
262262

263263
RedisModule_Free(PhySQLiteDB->name);
264264
sqlite3_close(PhySQLiteDB->connection);
@@ -278,11 +278,11 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
278278
.aof_rewrite = NULL,
279279
.free = FreePhySQLiteDB};
280280

281-
PersistentSQLiteDB = RedisModule_CreateDataType(
281+
RediSQL_SQLiteDB = RedisModule_CreateDataType(
282282
ctx, "Per_DB_Co",
283283
PERSISTENTSQLITEDB_ENCODING_VERSION, &tm);
284284

285-
if (PersistentSQLiteDB == NULL) return REDISMODULE_ERR;
285+
if (RediSQL_SQLiteDB == NULL) return REDISMODULE_ERR;
286286

287287
if (RedisModule_CreateCommand(ctx, "rediSQL.EXEC", ExecCommand,
288288
"deny-oom random no-cluster", 1, 1, 1) == REDISMODULE_ERR){

0 commit comments

Comments
 (0)