cache

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL = 24 * time.Hour

DefaultTTL is the default time-to-live for cache entries

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// GetWorkflow retrieves a workflow file from the cache
	// Returns the workflow file and a boolean indicating if it was found
	GetWorkflow(path string) (*types.WorkflowFile, bool)

	// SetWorkflow stores a workflow file in the cache
	SetWorkflow(path string, workflow *types.WorkflowFile)

	// GetActionResults retrieves action results from the cache
	// Returns the results and a boolean indicating if they were found
	GetActionResults(actionRef string) ([]types.DeepResult, bool)

	// SetActionResults stores action results in the cache
	SetActionResults(actionRef string, results []types.DeepResult)

	// Clear empties the cache
	Clear()

	// Close releases any resources used by the cache
	Close() error
}

Cache defines the interface for caching workflow files and action results

type CacheOption

type CacheOption func(*SQLiteCache)

CacheOption is a functional option for configuring the SQLiteCache

func WithCachePath

func WithCachePath(path string) CacheOption

WithCachePath sets a custom path for the cache database

func WithTTL

func WithTTL(ttl time.Duration) CacheOption

WithTTL sets the time-to-live for cache entries

type SQLiteCache

type SQLiteCache struct {
	// contains filtered or unexported fields
}

SQLiteCache is a persistent cache implementation using SQLite

func NewSQLiteCache

func NewSQLiteCache(opts ...CacheOption) (*SQLiteCache, error)

NewSQLiteCache creates a new SQLite-based cache with the specified options

func (*SQLiteCache) Clear

func (c *SQLiteCache) Clear()

Clear empties the cache

func (*SQLiteCache) Close

func (c *SQLiteCache) Close() error

Close closes the database connection and stops the cleanup goroutine

func (*SQLiteCache) GetActionResults

func (c *SQLiteCache) GetActionResults(actionRef string) ([]types.DeepResult, bool)

GetActionResults retrieves action results from the cache

func (*SQLiteCache) GetFileContent

func (c *SQLiteCache) GetFileContent(owner, repo, path, sha string) (string, int, bool)

GetFileContent retrieves file content from the cache Returns the content, status code, and whether it was found in cache

func (*SQLiteCache) GetWorkflow

func (c *SQLiteCache) GetWorkflow(path string) (*types.WorkflowFile, bool)

GetWorkflow retrieves a workflow file from the cache

func (*SQLiteCache) SetActionResults

func (c *SQLiteCache) SetActionResults(actionRef string, results []types.DeepResult)

SetActionResults stores action results in the cache

func (*SQLiteCache) SetFileContent

func (c *SQLiteCache) SetFileContent(owner, repo, path, sha string, content string, statusCode int)

SetFileContent stores file content in the cache The statusCode parameter allows caching of 404 responses

func (*SQLiteCache) SetWorkflow

func (c *SQLiteCache) SetWorkflow(path string, wf *types.WorkflowFile)

SetWorkflow stores a workflow file in the cache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL