Files
steampipe/pkg/db/db_client/db_client_cache_control.go
kaidaguerre 404dd35e21 Update database code to use pgx interface so we can leverage the connection pool hook functions to pre-warm connections. Closes #2422 (#2438)
* Provide feedback for failed prepared statements
* Move error functions to error_helpers
* Make maintenance client retriable
2022-10-05 12:38:57 +01:00

35 lines
868 B
Go

package db_client
import (
"context"
"fmt"
"github.com/turbot/steampipe/pkg/constants"
)
// CacheOn implements Client
func (c *DbClient) CacheOn(ctx context.Context) error {
return c.executeCacheCommand(ctx, constants.CommandCacheOn)
}
// CacheOff implements Client
func (c *DbClient) CacheOff(ctx context.Context) error {
return c.executeCacheCommand(ctx, constants.CommandCacheOff)
}
// CacheClear implements Client
func (c *DbClient) CacheClear(ctx context.Context) error {
return c.executeCacheCommand(ctx, constants.CommandCacheClear)
}
func (c *DbClient) executeCacheCommand(ctx context.Context, controlCommand string) error {
_, err := c.pool.Exec(ctx, fmt.Sprintf(
"insert into %s.%s (%s) values ('%s')",
constants.CommandSchema,
constants.CommandTableCache,
constants.CommandTableCacheOperationColumn,
controlCommand,
))
return err
}