src/graph/graphcontext.c
/* _GraphContext_Create tries to get a graph context, and if it does not exists, create a new one.
 * The try-get-create flow is done when module global lock is acquired, to enforce consistency
 * while BGSave is called. */
_GraphContext_Create tries to get a graph context, and if it does not exists, create a new one.
The try-get-create flow is done when module global lock is acquired, to enforce consistency
while BGSave is called.
_GraphContext_Create tries to get a graph context and if it does not exists create a new one . The try - get - create flow is done when module global lock is acquired to enforce consistency while BGSave is called .
static GraphContext *_GraphContext_Create(RedisModuleCtx *ctx, const char *graph_name,
										  size_t node_cap, size_t edge_cap) {
	GraphContext *gc = GraphContext_New(graph_name, node_cap, edge_cap);
	RedisModuleString *graphID = RedisModule_CreateString(ctx, graph_name, strlen(graph_name));
	RedisModuleKey *key = RedisModule_OpenKey(ctx, graphID, REDISMODULE_WRITE);
	RedisModule_ModuleTypeSetValue(key, GraphContextRedisModuleType, gc);
	GraphContext_RegisterWithModule(gc);
	RedisModule_FreeString(ctx, graphID);
	RedisModule_CloseKey(key);
	return gc;
}
static GraphContext * _GraphContext_Create ( RedisModuleCtx * ctx , const char * graph_name , size_t node_cap , size_t edge_cap ) { GraphContext * gc = GraphContext_New ( graph_name , node_cap , edge_cap ) ; RedisModuleString * graphID = RedisModule_CreateString ( ctx , graph_name , strlen ( graph_name ) ) ; RedisModuleKey * key = RedisModule_OpenKey ( ctx , graphID , REDISMODULE_WRITE ) ; RedisModule_ModuleTypeSetValue ( key , GraphContextRedisModuleType , gc ) ; GraphContext_RegisterWithModule ( gc ) ; RedisModule_FreeString ( ctx , graphID ) ; RedisModule_CloseKey ( key ) ; return gc ; }
_GraphContext_Create tries to get a graph context, and if it does not exists, create a new one.
_GraphContext_Create tries to get a graph context and if it does not exists create a new one .
// Create and initialize a graph context. // Set value in key. // Register graph context for BGSave.