Static Graph / Connection #139
-
Hi, I'm using Gremlinq in Azure FunctionApp. Would there be any problems in caching the graph object created from configure environment? public static IGremlinQuerySource MakeGraph(ILogger log) {
if (_graph != null) return _graph; // static _graph
_graph = GremlinQuerySource.g
.ConfigureEnvironment(e => e.UseLogger(log))
.ConfigureEnvironment(e => e
.UseModel(GraphModel
.FromBaseTypes<Vertex, Edge>(l =>
l.IncludeAssembliesOfBaseTypes())
.ConfigureProperties(model =>
model.ConfigureElement<Vertex>(conf =>
conf.IgnoreOnUpdate(x => x.PartitionKey))))
.UseCosmosDb(builder => builder
.At(new Uri(ConnectionString), DbName, GraphName)
.AuthenticateBy(PrimaryKey)));
return _graph;
} Are there any recommended patterns to use Gremlinq in this manner? Thanks so much, |
Beta Was this translation helpful? Give feedback.
Answered by
danielcweber
Feb 15, 2021
Replies: 1 comment 1 reply
-
Caching is actually highly recommended. Preferrably, you'd register an IGremlinQuerySource via a dependency injection container (the one built into ASP.NET Core and Azure functions will already do) so you don't have to manage its lifetime by yourself. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
navilan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Caching is actually highly recommended. Preferrably, you'd register an IGremlinQuerySource via a dependency injection container (the one built into ASP.NET Core and Azure functions will already do) so you don't have to manage its lifetime by yourself.