fcache

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

README

fcache

pipeline status coverage report Contributor Covenant

Implementation of handling of gob caches.

Install

go get -u lab.madbox.synology.me/gophers/fcache

Examples

// Define the struct to use
type Cache struct {
  Dict map[int]map[time.Month]map[int]string
  Updated time.Time
}

// Instance the struct
cache := new(Cache)

// Load the .gob file into the instanced struct
if err := fcache.LoadGobFile("/path/to/cache.gob", cache); err != nil {
  // Handle failed load of .gob file
}
// cache is now populated
fmt.Println("cache was updated:", cache.Updated)

// After modifying the struct's content, use this to write the .gob back to disk
if err := fcache.WriteGobFile("/path/to/cache.gob", cache); err != nil {
  // Handle failed write of .gob file
}

// If you would like to compress the cache using zlib, use the functions
// LoadGobzFile and WriteGobzFile to load and write the cache.

Contributing

When contributing to this project, please note our Code of Conduct.

License

The GNU General Public License v3.0 (GPLv3) - see LICENSE for more details

Documentation

Overview

Package fcache implements handling of gob caches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGobFile

func LoadGobFile(path string, cache interface{}) error

LoadGobFile decodes a gob file into given interface.

func LoadGobzFile

func LoadGobzFile(path string, cache interface{}) error

LoadGobzFile decodes a compressed gob file into given interface.

func WriteGobFile

func WriteGobFile(path string, cache interface{}) error

WriteGobFile encodes a given interface into a file.

func WriteGobzFile

func WriteGobzFile(path string, cache interface{}) error

WriteGobzFile encodes and compresses a given interface into a file.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL