Documentation
¶
Index ¶
- type CacheService
- type DynamoDBClient
- type DynamoPredictionCache
- func (c *DynamoPredictionCache) GetPredictions(ctx context.Context, stationID string, date time.Time) (*models.TidePredictionRecord, error)
- func (c *DynamoPredictionCache) SavePredictions(ctx context.Context, record models.TidePredictionRecord) error
- func (c *DynamoPredictionCache) SavePredictionsBatch(ctx context.Context, records []models.TidePredictionRecord) error
- type GraphQLCache
- type GraphQLCacheEntry
- type LRUCacheEntry
- type LRUCacheService
- func (c *LRUCacheService) Clear()
- func (c *LRUCacheService) GetCacheStats() map[string]uint64
- func (c *LRUCacheService) GetPredictions(ctx context.Context, stationID string, date time.Time) (*models.TidePredictionRecord, error)
- func (c *LRUCacheService) SavePredictions(ctx context.Context, record models.TidePredictionRecord) error
- func (c *LRUCacheService) SavePredictionsBatch(ctx context.Context, records []models.TidePredictionRecord) error
- type S3Client
- type S3StationCache
- type StationCache
- type StationListCacheProvider
- type StationListCacheRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheService ¶
type DynamoDBClient ¶
type DynamoDBClient interface {
GetItem(context.Context, *dynamodb.GetItemInput, ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
PutItem(context.Context, *dynamodb.PutItemInput, ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
BatchWriteItem(context.Context, *dynamodb.BatchWriteItemInput, ...func(*dynamodb.Options)) (*dynamodb.BatchWriteItemOutput, error)
ListTables(context.Context, *dynamodb.ListTablesInput, ...func(*dynamodb.Options)) (*dynamodb.ListTablesOutput, error)
}
DynamoDBClient interface defines the DynamoDB operations we use
func NewDynamoClient ¶
func NewDynamoClient(ctx context.Context) (DynamoDBClient, error)
NewDynamoClient creates a new DynamoDB client based on environment
type DynamoPredictionCache ¶
type DynamoPredictionCache struct {
// contains filtered or unexported fields
}
DynamoPredictionCache handles caching tide predictions in DynamoDB
func NewDynamoPredictionCache ¶
func NewDynamoPredictionCache(client DynamoDBClient, cacheConfig *config.CacheConfig) *DynamoPredictionCache
func (*DynamoPredictionCache) GetPredictions ¶
func (c *DynamoPredictionCache) GetPredictions(ctx context.Context, stationID string, date time.Time) (*models.TidePredictionRecord, error)
GetPredictions retrieves cached predictions for a station and date
func (*DynamoPredictionCache) SavePredictions ¶
func (c *DynamoPredictionCache) SavePredictions(ctx context.Context, record models.TidePredictionRecord) error
SavePredictions saves predictions to the cache
func (*DynamoPredictionCache) SavePredictionsBatch ¶
func (c *DynamoPredictionCache) SavePredictionsBatch(ctx context.Context, records []models.TidePredictionRecord) error
SavePredictionsBatch saves multiple prediction records to the cache
type GraphQLCache ¶
type GraphQLCache struct {
// contains filtered or unexported fields
}
func NewGraphQLCache ¶
func NewGraphQLCache(cfg *config.CacheConfig) (*GraphQLCache, error)
func (*GraphQLCache) Add ¶
func (c *GraphQLCache) Add(_ context.Context, key string, value interface{})
func (*GraphQLCache) Clear ¶
func (c *GraphQLCache) Clear()
type GraphQLCacheEntry ¶
type LRUCacheEntry ¶
type LRUCacheEntry struct {
Data *models.TidePredictionRecord
ExpiresAt time.Time
}
LRUCacheEntry wraps the cached data with metadata
type LRUCacheService ¶
type LRUCacheService struct {
// contains filtered or unexported fields
}
LRUCacheService provides a two-layer caching system using LRU and DynamoDB
func NewCacheService ¶
func NewCacheService(ctx context.Context, config *config.CacheConfig) (*LRUCacheService, error)
NewCacheService creates a new cache service with both LRU and DynamoDB caching
func (*LRUCacheService) Clear ¶
func (c *LRUCacheService) Clear()
Clear removes all entries from the LRU cache
func (*LRUCacheService) GetCacheStats ¶
func (c *LRUCacheService) GetCacheStats() map[string]uint64
GetCacheStats returns statistics about cache hits and misses
func (*LRUCacheService) GetPredictions ¶
func (c *LRUCacheService) GetPredictions(ctx context.Context, stationID string, date time.Time) (*models.TidePredictionRecord, error)
GetPredictions tries to get predictions first from LRU cache, then from DynamoDB
func (*LRUCacheService) SavePredictions ¶
func (c *LRUCacheService) SavePredictions(ctx context.Context, record models.TidePredictionRecord) error
SavePredictions saves predictions to both LRU and DynamoDB caches
func (*LRUCacheService) SavePredictionsBatch ¶
func (c *LRUCacheService) SavePredictionsBatch(ctx context.Context, records []models.TidePredictionRecord) error
SavePredictionsBatch saves multiple predictions to both caches
type S3Client ¶
type S3Client interface {
GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}
S3Client defines the interface for S3 operations we need
type S3StationCache ¶
type S3StationCache struct {
// contains filtered or unexported fields
}
S3StationCache provides caching for station lists in S3
func (*S3StationCache) GetStations ¶
GetStations retrieves stations from S3 cache if available and valid
func (*S3StationCache) SaveStations ¶
SaveStations saves stations to S3 cache
type StationCache ¶
type StationCache struct {
// contains filtered or unexported fields
}
func NewStationCache ¶
func NewStationCache(cacheConfig *config.CacheConfig) *StationCache
func (*StationCache) GetStations ¶
func (c *StationCache) GetStations() []models.Station
func (*StationCache) SetStations ¶
func (c *StationCache) SetStations(stations []models.Station)