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

Method loadFromDatabase

pkg/cache/db.go:338–354  ·  view source on GitHub ↗
(ctx context.Context, cacheKey string)

Source from the content-addressed store, hash-verified

336var dependentExpirationDuration = 24 * time.Hour
337
338func (c *PostgreSQLDependentCache) loadFromDatabase(ctx context.Context, cacheKey string) (*Response, error) {
339 var response Response
340 err := c.pool.QueryRow(
341 ctx,
342 "SELECT value, http_status_code, http_content_type FROM cache WHERE key=$1",
343 cacheKey,
344 ).Scan(&response.Payload, &response.StatusCode, &response.ContentType)
345 if err == nil {
346 return &response, nil
347 }
348
349 if err != pgx.ErrNoRows {
350 return nil, err
351 }
352
353 return nil, nil
354}
355
356func (c *PostgreSQLDependentCache) Get(ctx context.Context, key string) ([]byte, string, error) {
357 log := logger.FromContext(ctx)

Callers

nothing calls this directly

Calls 1

QueryRowMethod · 0.65

Tested by

no test coverage detected