gosqlredis

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

gosqlredis

Go Reference Build

Go library that stores data in Redis with SQL-like schema. The goal of this library is we can store data in Redis with table form.

What is gosqlredis used for

  • Cache data effectively without data duplication in Redis
  • Store data table in memory database

How to use

go get -u github.com/kaharman/gosqlredis

What you need

  1. Golang struct with Redis tag
  2. Data that you want to store

Supported data type

  1. Standard Golang data type
  2. time data type
  3. database/sql data type

License

gosqlredis is available under the Apache License, Version 2.0.

Documentation

Index

Constants

View Source
const (
	// MaxUint32 maximum value for uint32
	MaxUint32 = ^uint32(0)

	// MinUint32 minimum value for uint32
	MinUint32 = 0

	// MaxInt32 maximum value for int32
	MaxInt32 = int(MaxUint32 >> 1)

	// MinInt32 minimum value for int32
	MinInt32 = -MaxInt32 - 1

	// MaxUint64 maximum value for uint64
	MaxUint64 = ^uint64(0)

	// MinUint64 minimum value for uint64
	MinUint64 = 0

	// MaxInt64 maximum value for int64
	MaxInt64 = int(MaxUint64 >> 1)

	// MinInt64 maximum value for int64
	MinInt64 = -MaxInt64 - 1
)

Variables

This section is empty.

Functions

func ClearDataRedis

func ClearDataRedis(redisPool *redis.Pool, redisDatabase uint64, keyTable string) error

ClearDataRedis clear all data table in Redis

func DeleteDataRedis

func DeleteDataRedis(redisPool *redis.Pool, redisDatabase uint64, keyTable string, id string, index ...Index) error

DeleteDataRedis delete single data from Redis

func GetListRedisDataToStruct

func GetListRedisDataToStruct(redisPool *redis.Pool, redisDatabase uint64, keyTable string, sqlStruct interface{}) (int64, interface{}, error)

GetListRedisDataToStruct get multi row data save to data structure

func GetListRedisDataToStructSorted

func GetListRedisDataToStructSorted(redisPool *redis.Pool, redisDatabase uint64, keyTable string, sqlStruct interface{}, desc bool, index Index, limit int, offset int) (int64, interface{}, error)

GetListRedisDataToStructSorted get multi row data with sorted functionality save to data structure

func GetRedisDataToStruct

func GetRedisDataToStruct(redisPool *redis.Pool, redisDatabase uint64, keyTable string, sqlStruct interface{}, id string) (interface{}, error)

GetRedisDataToStruct get single data save to data structure

func InsertSQLDataToRedis

func InsertSQLDataToRedis(redisPool *redis.Pool, sqlData interface{}, redisDatabase uint64, keyTable string, id string, index ...Index) error

InsertSQLDataToRedis insert data from structured data into Redis

Types

type Index

type Index struct {
	Name string
	Type IndexType
}

Index structure with index name and index type

type IndexType

type IndexType string

IndexType determine is it index with number type or string type

const (
	// String is string type
	String IndexType = "string"

	// Number is number type
	Number IndexType = "number"
)

Jump to

Keyboard shortcuts

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