cache

package
v0.0.0-...-f8246e0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package cache implements a simple file-based cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

A Cache is a directory holding cached data.

func Create

func Create(name string) (*Cache, error)

Create returns a cache using the named subdirectory of the user's cache directory. For example, on macOS, Create("myprog") uses $HOME/Library/Caches/myprog. Create creates the directory if it does not already exist.

func Disabled

func Disabled() *Cache

Disabled returns a Cache that is always empty. Reads always return no result, and writes succeed but are discarded.

func (*Cache) Read

func (c *Cache) Read(name string) ([]byte, time.Time, error)

Read reads the file with the given name in the cache. It returns the file content, its last modification time, and any error encountered. If the file does not exist in the cache, Read returns nil, time.Time{}, nil.

func (*Cache) Write

func (c *Cache) Write(name string, data []byte) error

Write writes data to the file with the given name in the cache.

Jump to

Keyboard shortcuts

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