Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(model CacheModel)
Init sets the package-level CacheModel used by @call Func wrappers.
Types ¶
type CacheModel ¶
type CacheModel interface {
Set(ctx context.Context, key string, value any, ttl time.Duration) error
Get(ctx context.Context, key string) (string, error)
Delete(ctx context.Context, key string) error
}
CacheModel provides key-value + TTL storage for data efficiency (caching).
func NewMemoryCache ¶
func NewMemoryCache() CacheModel
NewMemoryCache creates an in-memory CacheModel. Data is lost on restart.
func NewPostgresCache ¶
NewPostgresCache creates a CacheModel backed by PostgreSQL. It auto-creates the fullend_cache table if not exists.
type DeleteRequest ¶
type DeleteRequest struct {
Key string
}
type DeleteResponse ¶
type DeleteResponse struct{}
func Delete ¶
func Delete(req DeleteRequest) (DeleteResponse, error)
type GetRequest ¶
type GetRequest struct {
Key string
}
type GetResponse ¶
type GetResponse struct {
Value string
}
func Get ¶
func Get(req GetRequest) (GetResponse, error)
type SetRequest ¶
type SetResponse ¶
type SetResponse struct{}
func Set ¶
func Set(req SetRequest) (SetResponse, error)
Source Files
¶
- cache_model.go
- default_model.go
- delete.go
- delete_request.go
- delete_response.go
- get.go
- get_request.go
- get_response.go
- memory_cache.go
- memory_cache_delete.go
- memory_cache_get.go
- memory_cache_set.go
- memory_entry.go
- new_memory_cache.go
- new_postgres_cache.go
- postgres_cache.go
- postgres_cache_delete.go
- postgres_cache_get.go
- postgres_cache_set.go
- set.go
- set_request.go
- set_response.go
Click to show internal directories.
Click to hide internal directories.