Documentation
¶
Index ¶
- func ConnectCache(cache Cache) error
- func DisconnectCache(cache Cache) error
- type Cache
- type Chunk
- type Redis
- func (r *Redis) ChangeFileState(hash string, saved bool) error
- func (r *Redis) CheckFileUpload(hash string) (bool, error)
- func (r *Redis) CloseConnection() error
- func (r *Redis) GetChunkList(hash string, name string) (*[]Chunk, error)
- func (r *Redis) GetFileLocation(hash string) (string, error)
- func (r *Redis) InitConnection() error
- func (r *Redis) InitFileLocation(hash string, addr string) error
- func (r *Redis) InsertOneChunk(hash string, chunk Chunk) error
- func (r *Redis) RemoveAllRecords(hash string) error
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectCache ¶
ConnectCache is function which load the database.
func DisconnectCache ¶
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 (*Redis) ChangeFileState ¶
ChangeFileState init the file's state for the server check.
func (*Redis) CheckFileUpload ¶
CheckFileUpload check the state of the file.
func (*Redis) CloseConnection ¶
CloseConnection close the connection with the cache.
func (*Redis) GetChunkList ¶
GetChunkList will return this file's all chunks.
func (*Redis) GetFileLocation ¶
GetFileLocation able to get the file in which server.
func (*Redis) InitConnection ¶
InitConnection initialize redis connection settings.
func (*Redis) InitFileLocation ¶
InitFileLocation initialize the location of this file when the frist time it comes.
func (*Redis) InsertOneChunk ¶
InsertOneChunk is a function insert one chunk in the cache.
func (*Redis) RemoveAllRecords ¶
RemoveAllRecords is a function which run after merge or error.