MCPcopy
hub / github.com/dosco/graphjin / dbFragmentKey

Method dbFragmentKey

core/cache_fragment.go:196–219  ·  view source on GitHub ↗
(
	ctx context.Context,
	kind string,
	dbName string,
	querySQL string,
	args []interface{},
	qc *qcode.QCode,
)

Source from the content-addressed store, hash-verified

194}
195
196func (s *gstate) dbFragmentKey(
197 ctx context.Context,
198 kind string,
199 dbName string,
200 querySQL string,
201 args []interface{},
202 qc *qcode.QCode,
203) string {
204 if !s.fragmentCacheEnabled(qc) {
205 return ""
206 }
207 var schemaHash string
208 if s.gj != nil {
209 if dbCtx, ok := s.gj.GetDatabase(dbName); ok && dbCtx.dbinfo != nil {
210 schemaHash = fmt.Sprintf("%x", dbCtx.dbinfo.Hash())
211 }
212 }
213 return s.buildFragmentCacheKey(ctx, kind, map[string]interface{}{
214 "database": dbName,
215 "schema_hash": schemaHash,
216 "sql": querySQL,
217 "args": cacheableArgs(args),
218 })
219}
220
221func cacheableArgs(args []interface{}) []string {
222 if len(args) == 0 {

Callers 3

executeMethod · 0.95

Calls 5

fragmentCacheEnabledMethod · 0.95
buildFragmentCacheKeyMethod · 0.95
cacheableArgsFunction · 0.85
HashMethod · 0.80
GetDatabaseMethod · 0.65

Tested by

no test coverage detected