MCPcopy Create free account
hub / github.com/cloudwan/gohan / ListContext

Method ListContext

db/sql/cached_transaction.go:93–110  ·  view source on GitHub ↗

List resources in the db

(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator)

Source from the content-addressed store, hash-verified

91
92//List resources in the db
93func (tx *CachedTransaction) ListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error) {
94 sc := listContextHelper(s, filter, options, pg)
95
96 list, total, wasCached, _, err := tx.getCached(s.ID, sc)
97
98 if err != nil {
99 return
100 }
101
102 if !wasCached {
103 metrics.UpdateCounter(1, "tx.%s.cache.miss", s.ID)
104 list, total, err = tx.TxInterface.ListContext(ctx, s, filter, options, pg)
105 tx.saveCache(s.ID, sc, list, total, false, err)
106 } else {
107 metrics.UpdateCounter(1, "tx.%s.cache.hit", s.ID)
108 }
109 return
110}
111
112func (tx *CachedTransaction) createKey(schemaID string, sc *selectContext) (string, error) {
113 filterHash, err := hashstructure.Hash(sc.filter, nil)

Callers 2

ListMethod · 0.95
FetchContextMethod · 0.95

Calls 4

getCachedMethod · 0.95
saveCacheMethod · 0.95
listContextHelperFunction · 0.85
ListContextMethod · 0.65

Tested by

no test coverage detected