dskstore

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: MIT Imports: 10 Imported by: 0

README

dskstore

Store file in a multi-level disk structure

Code example

d, err := dskstore.NewDskStore("storage", 6, 4)
if err != nil {
    panic(err)
}
  • create storage with 6 partitions and 4-level depth
if err = d.Clean(); err != nil {
    panic(err)
}
  • cleanup storage
if err = d.Store("00000001.txt", strings.NewReader("test data")); err != nil {
    panic(err)
}
  • store provided content of "00000001.txt" in storage/3/9/9/a/f/99af904a8245824376beaab015e49a9d8a2db278.txt
if !d.Exists("00000001.txt") {
    panic("object doesn't exist")
}
  • check object existence
data, err := d.Retrieve("00000001.txt")
if err != nil {
    panic(err)
}
  • retrieve content of "00000001.txt"

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	MaxPartitions = 16
	MaxLevels     = sha1.Size * 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DskStore

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

func NewDskStore

func NewDskStore(path string, prt, lvl int) (d *DskStore, err error)

func (*DskStore) Clean

func (d *DskStore) Clean() (err error)

func (*DskStore) Exists

func (d *DskStore) Exists(fn string) bool

func (*DskStore) Retrieve

func (d *DskStore) Retrieve(fn string) (data []byte, err error)

func (*DskStore) Store

func (d *DskStore) Store(fn string, src io.Reader) (err error)

Jump to

Keyboard shortcuts

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