server

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	ID int
	Records
}

Database represents a database.

func NewDatabaseWithID

func NewDatabaseWithID(id int) *Database

NewDatabaseWithID returns a new database with the specified ID.

type Databases

type Databases map[int]*Database

Databases represents a database map.

func (Databases) GetDatabase

func (dbs Databases) GetDatabase(id int) (*Database, bool)

GetDatabase returns the database with the specified ID.

type Record

type Record struct {
	Key       string
	Data      []byte
	Timestamp time.Time
	TTL       time.Duration
}

Record represents a database record.

type Records

type Records map[string]*Record

Records represents a database record map.

func (Records) GetRecord

func (rmap Records) GetRecord(key string) (*Record, bool)

GetRecord sets the specified record into the records

func (Records) SetRecord

func (rmap Records) SetRecord(record *Record) error

SetRecord sets the specified record into the records

type Server

type Server struct {
	*redis.Server
	Databases
}

Server represents an example server.

func NewServer

func NewServer() *Server

NewServer returns an example server instance.

func (*Server) Get

func (server *Server) Get(ctx *redis.DBContext, key string, opt redis.GetOption) (*redis.Message, error)

func (*Server) GetDatabase

func (server *Server) GetDatabase(id int) *Database

GetDatabase returns the database with the specified ID.

func (*Server) Set

func (server *Server) Set(ctx *redis.DBContext, key string, val string, opt redis.SetOption) (*redis.Message, error)

Jump to

Keyboard shortcuts

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