Documentation ¶
Index ¶
- type Device
- type Forecast
- type Nop
- func (n *Nop) DeviceZip(ctx context.Context, deviceID string) (string, error)
- func (n *Nop) GetForecast(ctx context.Context, lat string, lon string) (*darksky.Forecast, error)
- func (n *Nop) GetPollen(ctx context.Context, zip string) (*pollen.Forecast, error)
- func (n *Nop) PutDeviceZip(ctx context.Context, deviceID string, zip string) error
- func (n *Nop) PutForecast(ctx context.Context, lat string, lon string, f *darksky.Forecast) error
- func (n *Nop) PutPollen(ctx context.Context, zip string, p *pollen.Forecast) error
- type Pollen
- type Redis
- func (c *Redis) DeviceZip(ctx context.Context, deviceID string) (string, error)
- func (c *Redis) GetForecast(ctx context.Context, lat, lon string) (*darksky.Forecast, error)
- func (c *Redis) GetPollen(ctx context.Context, zip string) (*pollen.Forecast, error)
- func (c *Redis) PutDeviceZip(ctx context.Context, deviceID, zip string) error
- func (c *Redis) PutForecast(ctx context.Context, lat, lon string, f *darksky.Forecast) error
- func (c *Redis) PutPollen(ctx context.Context, zip string, f *pollen.Forecast) error
- func (c *Redis) SetTTL(dur time.Duration)
- type RedisPool
- type WriteThroughDevice
- type WriteThroughForecast
- type WriteThroughPollen
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device interface { DeviceZip(ctx context.Context, deviceID string) (string, error) PutDeviceZip(ctx context.Context, deviceID, zip string) error }
Device is a device cache which caches deviceIDs to zipcodes to prevent the constant lookup of zipcode for deviceID
type Forecast ¶
type Forecast interface { GetForecast(ctx context.Context, lat, lon string) (*darksky.Forecast, error) PutForecast(ctx context.Context, lat, lon string, f *darksky.Forecast) error }
Forecast is a layer which caches darksky forecast results
type Nop ¶
type Nop struct { }
Nop is a cache that does nothing
func (*Nop) GetForecast ¶
func (*Nop) PutDeviceZip ¶
func (*Nop) PutForecast ¶
type Pollen ¶
type Pollen interface { GetPollen(ctx context.Context, zipcode string) (*pollen.Forecast, error) PutPollen(ctx context.Context, zipcode string, p *pollen.Forecast) error }
Pollen is a layer which caches pollen count information
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis is a cache that uses redis
func (*Redis) GetForecast ¶
GetForecast retrieves a cache forecast from the redis store. If no cache exists then nil, nil is returned.
func (*Redis) GetPollen ¶
GetPollen retrieves a cache forecast from the redis store. If no cache exists then nil, nil is returned.
func (*Redis) PutDeviceZip ¶
PutDeviceZip stores a zipcode for a deviceID
func (*Redis) PutForecast ¶
PutForecast stores a forecast to the redis store
type WriteThroughDevice ¶
type WriteThroughDevice struct {
// contains filtered or unexported fields
}
WriteThroughDevice is a cache layer that has a fallback layer
func NewWriteThroughDevice ¶
func NewWriteThroughDevice(cache Device, api alexa.API) *WriteThroughDevice
NewWriteThroughDevice creates a new WriteThrough cache
func (*WriteThroughDevice) DeviceZip ¶
func (w *WriteThroughDevice) DeviceZip(ctx context.Context, accessToken, deviceID string) (string, error)
DeviceZip first tries to retrieve a cached result and falls back to directly fetching to the API. If the API is used then results are stored in the cache store
type WriteThroughForecast ¶
type WriteThroughForecast struct {
// contains filtered or unexported fields
}
WriteThroughForecast is a cache layer that has a fallback layer
func NewWriteThroughForecast ¶
func NewWriteThroughForecast(cache Forecast, api *darksky.API) *WriteThroughForecast
NewWriteThroughForecast creates a new WriteThrough cache
func (*WriteThroughForecast) GetForecast ¶
func (w *WriteThroughForecast) GetForecast(ctx context.Context, lat, lon string) (*darksky.Forecast, error)
GetForecast first tries to retrieve a cached result and falls back to directly fetching to the API. If the API is used then results are stored in the cache store
type WriteThroughPollen ¶
type WriteThroughPollen struct {
// contains filtered or unexported fields
}
WriteThroughPollen is a cache layer that has a fallback layer
func NewWriteThroughPollen ¶
func NewWriteThroughPollen(cache Pollen, api *pollen.API) *WriteThroughPollen
NewWriteThroughPollen creates a new WriteThrough cache
func (*WriteThroughPollen) GetPollen ¶
func (w *WriteThroughPollen) GetPollen(ctx context.Context, loc *tz.Location) (*pollen.Forecast, error)
GetPollen first tries to retrieve a cached result and falls back to directly fetching to the API. If the API is used then results are stored in the cache store