server

package
v0.0.0-...-3ea892f Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(cfg *Config) error

Start initializes and runs the Redis-like server.

Types

type Config

type Config struct {
	// Addr should be of the format localhost:8080 or 192.168.0.12:8080 or :8080
	Addr string
}

type Database

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

Database represents the in-memory data store.

func (*Database) Del

func (db *Database) Del(key string) bool

Delete a key from the database.

func (*Database) Get

func (db *Database) Get(key string) (string, bool)

Get a value by key, checking for expiration.

func (*Database) ProcessCommand

func (db *Database) ProcessCommand(command string) string

ProcessCommand parses and executes commands.

func (*Database) Set

func (db *Database) Set(key, value string, ttl time.Duration)

Set a key to a value with an optional expiry time.

type Entry

type Entry struct {
	Value      string
	ExpiryTime time.Time
}

Entry stores a value and its expiry time.

Jump to

Keyboard shortcuts

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