filecache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 4 Imported by: 0

README

Go FileCache

Simple file-based cache.

Usage

package main

import "gitlab.com/kukymbrgo/filecache"

func main()  {
	
    // Initialize cache
    c, err := filecache.New("/path/to/cache/dir", "")
    if err != nil {
    	panic(err)
    } 
    
    // ... make some reader
}

Documentation

Index

Constants

View Source
const NamespaceDefault = "dft"

Default namespace

Variables

This section is empty.

Functions

This section is empty.

Types

type FileCache

type FileCache struct {

	// Path to the cache files directory
	Path string

	// Default namespace if left empty in functions params
	NamespaceDefault string
}

Cache

func New

func New(path string, namespaceDefault string) (*FileCache, error)

Create file cache instance

func (*FileCache) ItemPath

func (c *FileCache) ItemPath(key string, namespace string, relative bool) (string, error)

Get Key path

func (*FileCache) Key

func (c *FileCache) Key(key string) string

Get hex-encoded Key hash string

func (*FileCache) Reader

func (c *FileCache) Reader(key string, namespace string) (io.Reader, error)

Get cache item reader

func (*FileCache) WriteFromReader

func (c *FileCache) WriteFromReader(key string, source io.Reader, namespace string) error

Write data from reader to the cache item

Jump to

Keyboard shortcuts

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