List resources in the db
(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator)
| 91 | |
| 92 | //List resources in the db |
| 93 | func (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 | |
| 112 | func (tx *CachedTransaction) createKey(schemaID string, sc *selectContext) (string, error) { |
| 113 | filterHash, err := hashstructure.Hash(sc.filter, nil) |
no test coverage detected