redistypes

package module
v0.0.0-...-9cb517b Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 3 Imported by: 3

README

Redistypes

Build Status Coverage Status GoDoc BADGINATOR

Redistypes is a very thin wrapper around redigo that provides a convenient way to use Redis's data types in Go.

NOTE: this project has been archived because I don't have time to work on it.

Features

Go implementations of the following data types in Redis:

  1. List
  2. HyperLogLog
  3. Set (in progress)

More to come!

Documentation

See the GoDocs.

Installation

To download, run

go get github.com/MasterOfBinary/redistypes

Redistypes requires the following dependency:

Example

For a full, runnable example, see https://github.com/MasterOfBinary/goredistypes.

License

Redistypes is provided under the MIT licence. See LICENSE for more details.

Documentation

Overview

Package redistypes provides Redis data types in Go. It a very thin layer on top of https://github.com/garyburd/redigo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

type Type interface {
	// Name returns the name of the key in Redis.
	Name() string

	// Delete implements the Redis command DEL. If a key exists in Redis, it is
	// deleted and true is returned. If it does not exist, false is returned.
	//
	// See https://redis.io/commands/del.
	Delete() (bool, error)

	// Exists implements the Redis command EXISTS. It determines if the key exists in
	// Redis. Exists returns true if it exists or false if it does not.
	//
	// See https://redis.io/commands/exists.
	Exists() (bool, error)

	// Expire implements the Redis command EXPIRE. It sets a timeout (given in seconds)
	// on the key, after which the key is deleted automatically. To remove the timeout,
	// call the Persist method. For more information about timeouts, see the
	// documentation.
	//
	// Expire uses the Redis command EXPIRE, which has second precision. If timeout
	// has more precision than that, an error is returned to avoid ambiguity in rounding.
	// For a more precise version of Expire, see PExpire.
	//
	// Expire returns true if the key exists and the timeout was set, or false otherwise.
	//
	// See https://redis.io/commands/expire.
	Expire(timeout time.Duration) (bool, error)

	// PExpire implements the Redis command PEXPIRE. It sets a timeout (given in
	// milliseconds) on the key, after which the key is deleted automatically. To
	// remove the timeout, call the Persist method. For more information about timeouts,
	// see the documentation.
	//
	// PExpire uses the Redis command PEXPIRE, which has millisecond precision. If timeout
	// has more precision than that, an error is returned to avoid ambiguity in rounding.
	// For a less precise version of PExpire, see Expire.
	//
	// PExpire returns true if the key exists and the timeout was set, or false otherwise.
	//
	// See https://redis.io/commands/pexpire.
	PExpire(timeout time.Duration) (bool, error)

	// Persist implements the Redis command PERSIST. It causes a volatile key to persist.
	//
	// See https://redis.io/commands/persist.
	Persist() (bool, error)

	// Rename renames the key to newkey, both in the Type and in Redis. If
	// newkey already exists in Redis, it is overwritten.
	//
	// See https://redis.io/commands/rename.
	Rename(newkey string) error

	// RenameNX renames the key to newkey, both in the Type and in Redis. If
	// the key was renamed successfully, true is returned. If newkey already exists
	// in Redis, false is returned.
	//
	// See https://redis.io/commands/renamenx.
	RenameNX(newkey string) (bool, error)
}

Type is an interface containing methods that every Redis type supports. These methods operate on keys in Redis with name equal to Name(), and they do not depend on the type of value stored in the key.

func NewRedisType

func NewRedisType(conn redis.Conn, name string) Type

Directories

Path Synopsis
Package hyperloglog contains a Go implementation of the HyperLogLog data structure in Redis.
Package hyperloglog contains a Go implementation of the HyperLogLog data structure in Redis.
Package internal contains internal functions used by redistypes.
Package internal contains internal functions used by redistypes.
test
Package test contains functions used for testing in redistypes.
Package test contains functions used for testing in redistypes.
Package list contains a Go implementation of the list data structure in Redis.
Package list contains a Go implementation of the list data structure in Redis.

Jump to

Keyboard shortcuts

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