groupcache

package
v0.0.0-...-8e84a60 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package groupcache is an fs.FS wrapper for caching purposes built around Brad Fitzpatrick's groupcache.

This package behaves slightly different than our other cache packages due to its unique characteristics such as key groupings and automatic cache filling. These features which make groupcache great are slightly annoying in this context (nothing is perfect for everything).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS represents a fs.FS that implements OpenFile() and allows reading and writing to a groupcache.

func New

func New(picker groupcache.PeerPicker) (*FS, error)

New creates a new FS.

func (*FS) NewGroup

func (f *FS) NewGroup(name string, sizeInBytes int64) error

NewGroup creates a new groupcache group which acts like a top level directory. sizeInBytes is the maximum size in bytes that the group can hold. Trying to open a file in a path without a group that is recognized will fail.

func (*FS) Open

func (f *FS) Open(name string) (fs.File, error)

func (*FS) OpenFile

func (f *FS) OpenFile(name string, perms fs.FileMode, options ...jsfs.OFOption) (fs.File, error)

OpenFile implements fs.OpenFiler.OpenFile(). When writing a file, the file is not written until Close() is called on the file. Perms are ignored by OpenFile.

func (*FS) ReadFile

func (f *FS) ReadFile(name string) ([]byte, error)

ReadFile implements fs.ReadFileFS.ReadFile().

func (*FS) SetFiller

func (f *FS) SetFiller(fsys cache.CacheFS)

SetFiller implements cache.SetFiller.SetFiller().

func (*FS) Stat

func (f *FS) Stat(name string) (fs.FileInfo, error)

Stat implements fs.StatFS.Stat(). The FileInfo returned name and size can be used, but the others are static values. ModTime will always be the zero value. It should be noted that this is simple a bad wrapper on Open(), so the content is read as I did not see a way to query Redis for just the key size (and to be honest, I didn't dig to hard).

func (*FS) WriteFile

func (f *FS) WriteFile(name string, content []byte, perm fs.FileMode) error

WriteFile writes a file to name with content. This uses O_WRONLY | O_CREATE | O_TRUNC, so it will overrite an existing entry. If you passed WithWriteFileOFOptions(), it will use those options if name matches a regex. Passed perm must be 0644.

Directories

Path Synopsis
Package peerpicker provides a groupcache.PeerPicker that utilizes a LAN peer discovery mechanism and sets up the groupcache to use the HTTPPool for communication between nodes.
Package peerpicker provides a groupcache.PeerPicker that utilizes a LAN peer discovery mechanism and sets up the groupcache to use the HTTPPool for communication between nodes.
app
So....
So....

Jump to

Keyboard shortcuts

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