alg

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: GPL-2.0, GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

	GoBigdis is a persistent database that implements the Redis server protocol.
    Copyright (C) 2021  Riccardo Berto

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

	GoBigdis is a persistent database that implements the Redis server protocol.
    Copyright (C) 2021  Riccardo Berto

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

	GoBigdis is a persistent database that implements the Redis server protocol.
    Copyright (C) 2021  Riccardo Berto

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

	GoBigdis is a persistent database that implements the Redis server protocol.
    Copyright (C) 2021  Riccardo Berto

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BTree

type BTree struct {
}

type Bloom

type Bloom struct {
}

type Cache

type Cache struct {
	FSRWL    sync.RWMutex // RWMutex for filesystem access
	DataLock sync.Mutex   // used only by writers to implement the copy-on-write pattern
	MaxDBNum int          // the max number of the DBs to consider
	Root     string       // the parent folder of all the dbNum dirs
	Data     atomic.Value // [dbNum][first][second][third]bool, this is the field that represents the source of truth for the cache
	// contains filtered or unexported fields
}

func (*Cache) Add

func (c *Cache) Add(key Key)

func (*Cache) BuildCacheData

func (c *Cache) BuildCacheData()

BuildCacheData builds a new Cache index from the filesystem

func (*Cache) Match

func (c *Cache) Match(key Key) bool

Match returns true if the first config.CacheDepth bytes of key match any bytes of the respective levels of the Cache

func (*Cache) NewKey

func (c *Cache) NewKey(dbNum int, keyName []byte) Key

NewKey is a convenience function for Key struct generation

func (*Cache) Set

func (c *Cache) Set(key Key, value bool)

expensive, must sync with other writers

func (*Cache) Vacuum

func (c *Cache) Vacuum(dbMaxNum int, d time.Duration)

Vacuum keeps the structure in sync with the filesystem representation. It is needed for handling key removals. It must stop the world.

type Key

type Key struct {
	DB int

	HashedKey [32]byte // sha256 of the key
	// contains filtered or unexported fields
}

func (*Key) Encode

func (k *Key) Encode() string

Encode encodes HashedKey field with encoding/hex

func (*Key) FilePath

func (k *Key) FilePath() string

func (*Key) Level

func (k *Key) Level(nth int) string

Level returns the hex-encoded string of the nth byte

func (*Key) Level3

func (k *Key) Level3() []string

Level3 is a convenience function that returns the first 3 hex-encoded bytes of HashedKey

func (*Key) ParentPath

func (k *Key) ParentPath() string

Jump to

Keyboard shortcuts

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