MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _GraphContext_Create

Function _GraphContext_Create

src/graph/graphcontext.c:143–165  ·  view source on GitHub ↗

_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

Source from the content-addressed store, hash-verified

141// the try-get-create flow is done when module global lock is acquired
142// to enforce consistency while BGSave is called
143static GraphContext *_GraphContext_Create
144(
145 RedisModuleCtx *ctx,
146 const char *graph_name
147) {
148 // create and initialize a graph context
149 GraphContext *gc = GraphContext_New(graph_name);
150 RedisModuleString *graphID = RedisModule_CreateString(ctx, graph_name,
151 strlen(graph_name));
152
153 RedisModuleKey *key = RedisModule_OpenKey(ctx, graphID, REDISMODULE_WRITE);
154
155 // set value in key
156 RedisModule_ModuleTypeSetValue(key, GraphContextRedisModuleType, gc);
157
158 // register graph context for BGSave
159 GraphContext_RegisterWithModule(gc);
160
161 RedisModule_FreeString(ctx, graphID);
162 RedisModule_CloseKey(key);
163
164 return gc;
165}
166
167GraphContext *GraphContext_Retrieve
168(

Callers 1

GraphContext_RetrieveFunction · 0.85

Calls 2

GraphContext_NewFunction · 0.85

Tested by

no test coverage detected