cache

package
v0.0.0-...-d39c007 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

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
}

Cache implements a cache of nodes and handles that a Handler can use.

func New

func New(l log.Logger, rootNode Node) *Cache

New creates a new cache, pre-populated with a root node.

func (*Cache) AddHandle

func (c *Cache) AddHandle(handle Handle) (HandleInfo, error)

AddHandle stores a new handle.

func (*Cache) AddNode

func (c *Cache) AddNode(parent fine.Node, name string, node Node) (info NodeInfo, err error)

AddNode stores a new node. If the named node already exists, the node argument will be ignored and the reference count to the existing node will increase.

func (*Cache) GetHandle

func (c *Cache) GetHandle(id fine.Handle) (HandleInfo, Handle, error)

GetHandle returns the Handle for a Handle ID.

func (*Cache) GetNode

func (c *Cache) GetNode(id fine.Node) (NodeInfo, Node, error)

GetNode returns the node for ID.

func (*Cache) NodePath

func (c *Cache) NodePath(id fine.Node) (string, error)

NodePath returns the full disk path for a node.

func (*Cache) ReleaseHandle

func (c *Cache) ReleaseHandle(id fine.Handle) error

ReleaseHandle releases an existing handle.

func (*Cache) ReleaseNode

func (c *Cache) ReleaseNode(id fine.Node, refs uint64) error

ReleaseNode releases a node. refs are subtracted from the total reference count, and the node will be fully removed once refs decreases to 0.

func (*Cache) RenameNode

func (c *Cache) RenameNode(parent fine.Node, req *fine.RenameRequest) error

RenameNode renames a cached file. Returns ErrorNotExist if the source file isn't currently cached.

type Handle

type Handle interface {
	// Close is called when the Handle is fully removed from the cache.
	Close() error
}

type HandleInfo

type HandleInfo struct {
	ID fine.Handle
}

type Key

type Key struct {
	Parent fine.Node
	Name   string
}

type Node

type Node interface {
	// Close is called when the Node is fully removed from the cache.
	Close() error
}

type NodeInfo

type NodeInfo struct {
	ID         fine.Node // ID of the Node
	Generation uint64    // Generation of the ID
	Key        Key       // Key used to identify the node
}

Jump to

Keyboard shortcuts

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