Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPingFailed is returned if the initial ping to the database returns an error ErrPingFailed = errors.New("ping returned error") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache implements the gocondcache.Cache interface using PostgreSQL as the storage backend. It provides thread-safe operations for storing and retrieving cached HTTP responses.
func New ¶
New creates a new PostgreSQL cache instance with the provided configuration. It verifies the database connection, creates the necessary table structure, and optionally starts the cleanup task for expired items.
Returns an error if: - The database connection test fails - Table creation fails - Configuration validation fails
func (*Cache) Get ¶
Get retrieves a cache item from PostgreSQL by its key. It returns the cached item if found and not expired, or an appropriate error otherwise. Returns caches.ErrNoCacheItem if the item doesn't exist.
type Config ¶
type Config struct { // DeleteExpiredItems enables automatic cleanup of expired cache entries // through a background task. DeleteExpiredItems bool // ExpiredTaskTimer defines the interval at which the cleanup task runs. // Shorter durations may impact database performance. ExpiredTaskTimer time.Duration // ItemExpiration defines how long items remain valid in the database. // This is separate from the expiration time derived from conditional response headers. ItemExpiration time.Duration }
Config defines the configuration options for the PostgreSQL cache implementation.