bridges

package module
v0.0.0-...-af574e6 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 0 Imported by: 0

README

Go Bridges

This repo is intended to be used as a collection of wrappers of common Go libraries. This is the implementation of Bridge design pattern. By using Bridge design pattern we can make our source codes be more flexible and adaptable to changes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Json

type Json interface {
	// Unmarshal decodes JSON string to a struct
	// v should be a pointer
	Unmarshal(data []byte, v interface{}) error

	// Marshal encodes struct into JSON
	// v should not be a pointer
	Marshal(v interface{}) ([]byte, error)
}

Json module used for encoding and decoding JSON string to Golang's struct

type Redis

type Redis interface {
	// Get value of the specified key. Will return ErrNil if the return value is nil
	Get(key string) ([]byte, error)
	// Set sets value to key in redis without any additional options
	Set(key, value string) error
	Setex(key string, seconds int, value string) error
	// Setnx sets a value to a key with specified timeouts. Will return false if the key exists
	Setnx(key string, seconds int, value string) (bool, error)
	// HMGet gets a value of multiple fields from hash key. Will return ErrNil if the return value is nil
	HMGet(key string, fields ...string) ([][]byte, error)
	Exists(key string) (bool, error)
	Expire(key string, seconds int) (bool, error)
	ExpireAt(key string, timestamp int64) (bool, error)
	Incr(key string) (int64, error)
	Decr(key string) (int64, error)
	TTL(key string) (int64, error)
	HGet(key string, field string) ([]byte, error)
	HExists(key string, field string) (bool, error)
	HGetAll(key string) (map[string]string, error)
	HSet(key string, field string, value string) (bool, error)
	HKeys(key string) ([]string, error)
	HDel(key string, fields ...string) (int64, error)
	Del(key ...interface{}) (int64, error)

	// Close releases all the connections and resources to redis
	Close() error
}

Redis module is a client to connect to redis

type RedisJson

type RedisJson interface {
	Redis
	// GetUnmarshalled fetches value from redis key
	// v should be pointer
	GetUnmarshalled(key string, v interface{}) error

	// SetexMarshalled sets value with expiry
	// v should not be a pointer
	SetexMarshalled(key string, seconds int, v interface{}) error
}

RedisJson adds the capability to Redis by adding capabilities to Unmarshal and Marshal JSON on this very module

Directories

Path Synopsis
Package json is a generated GoMock package.
Package json is a generated GoMock package.
Package redis is a generated GoMock package.
Package redis is a generated GoMock package.
Package redisjson is a generated GoMock package.
Package redisjson is a generated GoMock package.
twitter

Jump to

Keyboard shortcuts

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