MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / SetCache

Method SetCache

internal/db/db.go:196–207  ·  view source on GitHub ↗

SetCache stores or replaces a pricing response in the cache.

(cacheKey string, resp *api.PricingAPIResponse)

Source from the content-addressed store, hash-verified

194
195// SetCache stores or replaces a pricing response in the cache.
196func (d *DB) SetCache(cacheKey string, resp *api.PricingAPIResponse) error {
197 data, err := json.Marshal(resp)
198 if err != nil {
199 return err
200 }
201 now := time.Now().UTC().Format(time.RFC3339)
202 _, err = d.conn.Exec(
203 "INSERT OR REPLACE INTO pricing_cache (cache_key, response_json, created_at) VALUES (?, ?, ?)",
204 cacheKey, string(data), now,
205 )
206 return err
207}
208
209// GetCacheStats returns (count, totalBytes) for pricing_cache.
210func (d *DB) GetCacheStats() (int, int, error) {

Callers 1

UpdateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected