cache

package
v0.0.0-...-9257e39 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectCache

func ConnectCache(cache Cache) error

ConnectCache is function which load the database.

func DisconnectCache

func DisconnectCache(cache Cache) error

DisconnectCache is function which disconnect the database.

Types

type Cache

type Cache interface {
	// Init function of this cache.
	InitConnection() error
	// Close function of this cache.
	CloseConnection() error
	// Insert a chunk info in a list which key is file's hash.
	InsertOneChunk(hash string, chunk Chunk) error
	// Get the chunks list in the cache.
	GetChunkList(hash string, name string) (*[]Chunk, error)
	// Remove all of chunks after merge or error.
	RemoveAllRecords(hash string) error
	// Init the file's state for the server check.
	ChangeFileState(hash string, saved bool) error
	// Check this file whether exist completely or not.
	CheckFileUpload(hash string) (bool, error)
	// Initialize the location of this file for reverse.
	InitFileLocation(hash string, addr string) error
	// Get the storage location of the file and get where it is.
	GetFileLocation(hash string) (string, error)
}

Cache interface defines the functions of the cache.

type Chunk

type Chunk struct {
	Name  string // name of the file this chunk belongs to.
	Hash  string // file hash to which this chunk belongs.
	Index int    // index of chunk in the file.
}

Chunk is the definition of a part of file. Remember the 'Hash' in this structure from the file not this hash.

type Redis

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

Here is the definition of the cache structure.

func NewRedis

func NewRedis(addr string, password string, size int) *Redis

func (*Redis) ChangeFileState

func (r *Redis) ChangeFileState(hash string, saved bool) error

ChangeFileState init the file's state for the server check.

func (*Redis) CheckFileUpload

func (r *Redis) CheckFileUpload(hash string) (bool, error)

CheckFileUpload check the state of the file.

func (*Redis) CloseConnection

func (r *Redis) CloseConnection() error

CloseConnection close the connection with the cache.

func (*Redis) GetChunkList

func (r *Redis) GetChunkList(hash string, name string) (*[]Chunk, error)

GetChunkList will return this file's all chunks.

func (*Redis) GetFileLocation

func (r *Redis) GetFileLocation(hash string) (string, error)

GetFileLocation able to get the file in which server.

func (*Redis) InitConnection

func (r *Redis) InitConnection() error

InitConnection initialize redis connection settings.

func (*Redis) InitFileLocation

func (r *Redis) InitFileLocation(hash string, addr string) error

InitFileLocation initialize the location of this file when the frist time it comes.

func (*Redis) InsertOneChunk

func (r *Redis) InsertOneChunk(hash string, chunk Chunk) error

InsertOneChunk is a function insert one chunk in the cache.

func (*Redis) RemoveAllRecords

func (r *Redis) RemoveAllRecords(hash string) error

RemoveAllRecords is a function which run after merge or error.

type Target

type Target struct {
	Hash     string // the hash of this file.
	Location string // the storage server's host.
}

Jump to

Keyboard shortcuts

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