indexdb

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package indexdb handles the storage for indexes.

Design

The db file name is index, and the key-value design in leveldb is:

Key:   <Name>
Value: <Stamp>:<Score>:<Average>

Cache

To access indexes faster in webapp, indexes are cached in memory, in a safemap with a RWLock.

Read operations are in cache.

Write operations are to persistence and cache.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when requested data not found.
	ErrNotFound = errors.New("indexdb: not found")
	// ErrCorrupted is returned when corrupted data found.
	ErrCorrupted = errors.New("indexdb: corrupted data found")
)

Functions

This section is empty.

Types

type DB

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

DB handles indexes storage.

func Open

func Open(fileName string) (*DB, error)

Open a DB by fileName.

func (*DB) All

func (db *DB) All() (l []*models.Index)

All returns all indexes.

func (*DB) Close

func (db *DB) Close() error

Close the DB.

func (*DB) Delete

func (db *DB) Delete(name string) error

Delete an index by name.

func (*DB) Filter

func (db *DB) Filter(pattern string) (l []*models.Index)

Filter indexes by pattern.

func (*DB) Get

func (db *DB) Get(name string) (*models.Index, error)

Get an index by name.

func (*DB) Len added in v0.0.5

func (db *DB) Len() int

Len returns the number of indexes.

func (*DB) Put

func (db *DB) Put(idx *models.Index) error

Put an index into db.

Jump to

Keyboard shortcuts

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