Documentation ¶
Index ¶
- Constants
- func FindCacheDir() (string, error)
- func FindCacheFile() (string, error)
- func ShouldUpdate(originalTime time.Time, minMinutesDifference int) bool
- type NauticalCache
- type NauticalCacheData
- func (cache *NauticalCacheData) CopyCurrentCache(extra_data string) error
- func (cache *NauticalCacheData) CopyCurrentCacheWithTimestamp() error
- func (cache *NauticalCacheData) Dump() error
- func (cache *NauticalCacheData) New() error
- func (cache *NauticalCacheData) ShouldUpdate(minMinutesDifference int) bool
Constants ¶
const ( CacheFile = "nautical_cache.json" TimeLayout = "2006-01-02_15-04-05" )
Variables ¶
This section is empty.
Functions ¶
func FindCacheDir ¶
FindCacheDir will find the nautical cache directory. First the environment variable NAUTICAL_CACHE_DIR is searched for. If this environment variable is not found, then the operating system is searched and directory is returned according to the system.
func FindCacheFile ¶
FindCacheFile find the full path to the cache file.
Types ¶
type NauticalCache ¶
type NauticalCache struct { // Buoys is the list of all buoys that are to be cached Buoys []noaa.Buoy `json:"buoys,omitempty"` // Sources is the list of all sources that are to be cached Sources []noaa.Source `json:"sources,omitempty"` // Time that the cache was created Time string `json:"time,omitempty"` }
NauticalCache contains the Buoys, Sources, and Time data for a cached instance
type NauticalCacheData ¶
type NauticalCacheData struct { // Full Filename (including path) to the cached data Filename string // CachedData is structure holding all cached data CachedData *NauticalCache }
NauticalCacheData is a wrapper for the NauticalCache struct that includes the Filename where the data is stored
func Load ¶
func Load(filename string) (*NauticalCacheData, error)
Load will load the data from a file into the NauticalCacheData
func (*NauticalCacheData) CopyCurrentCache ¶
func (cache *NauticalCacheData) CopyCurrentCache(extra_data string) error
CopyCurrentCache copies the current cached data to a new file where the extra data is appended to the original cached filename
func (*NauticalCacheData) CopyCurrentCacheWithTimestamp ¶
func (cache *NauticalCacheData) CopyCurrentCacheWithTimestamp() error
CopyCurrentCacheWithTimestamp Copies the data of the original file and renames the file with a timestamp.
func (*NauticalCacheData) Dump ¶
func (cache *NauticalCacheData) Dump() error
Dump outputs the nautical cache data to the filename specified in the cache struct
func (*NauticalCacheData) New ¶
func (cache *NauticalCacheData) New() error
func (*NauticalCacheData) ShouldUpdate ¶
func (cache *NauticalCacheData) ShouldUpdate(minMinutesDifference int) bool
ShouldUpdate will determine if an update should occur based on the time stored in the CacheData