cache

package
Version: v0.0.0-...-bf65384 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides an abstraction for data caching

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(string, interface{}) error
	Get(string, interface{}) (bool, error)
}

Cache is an interface for a Get/Set caching struct

type FS

type FS interface {
	Mkdir(path string, perms os.FileMode) error
	WriteFile(path string, data []byte, perms os.FileMode) error
	ReadFile(path string) ([]byte, error)
}

FS is an interface for interacting with the file system

type FSCache

type FSCache struct {
	CachePath string
	FS        FS
}

FSCache is an implementation of file-system cache using the FS interface

func (FSCache) Get

func (c FSCache) Get(key string, x interface{}) (bool, error)

Get gets the contents of the file (if exists) using `key` and Unmarshals it to the struct `x`

func (FSCache) Set

func (c FSCache) Set(key string, x interface{}) error

Set converts `x` to JSON and writes it to a file using `key`

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL