Documentation
¶
Overview ¶
Package cachereader implements the `whosonfirst/go-reader` interface with a caching layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCacheReader ¶
NewCacheReader will return a new `CacheReader` instance configured by 'uri' which is expected to take the form of:
cachereader://?reader={READER_URI}&cache={CACHE_URI}
Where {READER_URI} is expected to be a valid `whosonfirst/go-reader.Reader` URI and {CACHE_URI} is expected to be a valid `whosonfirst/go-cache.Cache` URI. Note that multiple "?reader=" parameter are supported; internally the `CacheReader` implementation uses a `whosonfirst/go-reader.MultiReader` instance for reading documents.
func NewCacheReaderWithOptions ¶ added in v1.1.0
func NewCacheReaderWithOptions(ctx context.Context, opts *CacheReaderOptions) (reader.Reader, error)
NewCacheReader will return a new `CacheReader` instance configured by 'opts'.
Types ¶
type CacheReader ¶
type CacheReader struct { reader.Reader // contains filtered or unexported fields }
type CacheReader implements the `whosonfirst/go-reader` interface for use with a caching layer for reading documents.
func (*CacheReader) Read ¶
func (cr *CacheReader) Read(ctx context.Context, key string) (io.ReadSeekCloser, error)
Read returns an `io.ReadSeekCloser` instance for the document resolved by `uri`. The document will also be added to the internal cache maintained by 'cr' if it not already present.
type CacheReaderOptions ¶ added in v1.1.0
type CacheReaderOptions struct { Reader reader.Reader Cache cache.Cache }
type CacheReaderOptions is a struct for use with the `NewCacheReaderWithOptions` method.
type CacheStatus ¶ added in v1.0.0
type CacheStatus uint8
type CacheStatus is a constant indicating the cache status for a read action
const ( // CacheNotFound signals that there are no recorded events for a cache lookup CacheNotFound CacheStatus = iota // CacheHit signals that the last read event was a cache HIT CacheHit // CacheHit signals that the last read event was a cache MISS CacheMiss )
func GetLastRead ¶ added in v1.0.0
func GetLastRead(cr reader.Reader, key string) (CacheStatus, bool)
GetLastRead returns the `CacheStatus` value for the last event using 'cr' to read 'path'.