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

Method Insert

pkg/cache/db.go:382–403  ·  view source on GitHub ↗
(
	ctx context.Context, key string, parentKey string, value []byte, contentType string,
)

Source from the content-addressed store, hash-verified

380}
381
382func (c *PostgreSQLDependentCache) Insert(
383 ctx context.Context, key string, parentKey string, value []byte, contentType string,
384) error {
385 log := logger.FromContext(ctx)
386
387 cacheKey := c.keyProvider.CacheKey(ctx, key)
388 if _, err := c.pool.Exec(
389 ctx,
390 "INSERT INTO dependent_values (key, parent_key, value, http_content_type, "+
391 "expiration_timestamp) VALUES ($1, $2, $3, $4, $5)",
392 cacheKey, parentKey, value, contentType, time.Now().Add(dependentExpirationDuration),
393 ); err != nil {
394 log.Errorw("Error inserting dependent value",
395 "cacheKey", cacheKey,
396 "parentKey", parentKey,
397 "error", err,
398 )
399 return err
400 }
401
402 return nil
403}
404
405func (c *PostgreSQLDependentCache) commit(ctx context.Context, parentKey string) error {
406 log := logger.FromContext(ctx)

Callers

nothing calls this directly

Calls 4

FromContextFunction · 0.92
CacheKeyMethod · 0.65
ExecMethod · 0.65
ErrorwMethod · 0.65

Tested by

no test coverage detected