MCPcopy Create free account
hub / github.com/Chatterino/api / Get

Method Get

pkg/cache/db.go:356–380  ·  view source on GitHub ↗
(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

354}
355
356func (c *PostgreSQLDependentCache) Get(ctx context.Context, key string) ([]byte, string, error) {
357 log := logger.FromContext(ctx)
358
359 cacheKey := c.keyProvider.CacheKey(ctx, key)
360 var value []byte
361 var contentType string
362
363 err := c.pool.QueryRow(
364 ctx,
365 "SELECT value, http_content_type FROM dependent_values WHERE key=$1",
366 cacheKey,
367 ).Scan(&value, &contentType)
368 if err != nil {
369 if err != pgx.ErrNoRows {
370 // An actual error
371 log.Warnw("Unhandled sql error", "error", err)
372 return nil, "", err
373 }
374
375 // Cache entry didn't exist
376 return nil, "", nil
377 }
378
379 return value, contentType, nil
380}
381
382func (c *PostgreSQLDependentCache) Insert(
383 ctx context.Context, key string, parentKey string, value []byte, contentType string,

Callers

nothing calls this directly

Calls 4

FromContextFunction · 0.92
CacheKeyMethod · 0.65
QueryRowMethod · 0.65
WarnwMethod · 0.65

Tested by

no test coverage detected