dir

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package dir implements an on-disk reference storage adapter.

To be able to use it, add an anonymous import to your main package:

import _ "github.com/digineo/texd/refstore/dir"

This registers the "dir://" and "memory://" adapters.

For configuration, use a DSN with the following shape:

dsn := "dir:///path/for/persistent/files?options"
dir, _ := refstore.NewStore(dsn, &refstore.KeepForever{})

Note the triple-slash: the scheme is "dir://", and the directory itself is /path/for/persistent/files. See New() for valid options.

Mostly for testing, this also provides a memory-backed adapter. It is STRONGLY recommended to use it only with a size-limited access list, as it may otherwise consume all available RAM:

rp, _ := refstore.NewAccessList(1000, 100 * units.MiB)
mem, _ := restore.NewStore("memory:", rp)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config *url.URL, rp refstore.RetentionPolicy) (refstore.Adapter, error)

New returns a new storage adapter.

This adapter takes only the path from the config URL. The path must point to an existing directory, and it must be writable, otherwise New returns an error.

The retention policy is applied immediately: in case of refstore.PurgeOnStart, existing file references will be deleted, and in case of refstore.AccessList, references are first ordered by mtime and added in order to the retention policies internal state (which may evict and delete files, if the policies limits are reached).

func NewMemory

func NewMemory(config *url.URL, rp refstore.RetentionPolicy) (refstore.Adapter, error)

NewMemory returns a memory-backed reference store adapter.

The config URL is ignored, all reference files are stored in a virtual file system at "/".

Like New, The retention policy is applied immediately. Note that due to the nature of (volatile) memory, refstore.PurgeOnStart and refstore.KeepForever behave the same way.

It is STRONGLY recommended to use NewMemotry only with a size-limited access list, as it may otherwise consume all available RAM.

Types

This section is empty.

Jump to

Keyboard shortcuts

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