database

package module
v0.0.0-...-00968f0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 6 Imported by: 0

README

database

database

Documentation

Index

Constants

View Source
const (
	MongoURL      = "mongodb://mongo:mongo@127.0.0.1:27017"
	MongoDatabase = "app"
	MongoTimeout  = 1 * time.Second
)

Variables

View Source
var (
	RedisURL = "redis://127.0.0.1:6379/0"
	RedisExp = 5 * time.Minute
)

Functions

This section is empty.

Types

type Mongo

type Mongo struct {
	Conn *mongo.Client
	Ctx  context.Context
}

func NewMongo

func NewMongo() *Mongo

func NewMongoWithURL

func NewMongoWithURL(url string) *Mongo

func (Mongo) Close

func (m Mongo) Close()

func (Mongo) Collection

func (m Mongo) Collection(collection string) *mongo.Collection

func (Mongo) Connect

func (m Mongo) Connect() bool

func (Mongo) Database

func (m Mongo) Database() *mongo.Database

type Redis

type Redis struct {
	Conn *redis.Client
	Ctx  context.Context
}

func NewRedis

func NewRedis() *Redis

func NewRedisWithURL

func NewRedisWithURL(url string) *Redis

func (Redis) Cache

func (r Redis) Cache(key string, callback func(...any) any, args ...any) any

func (Redis) Close

func (r Redis) Close()

func (Redis) Delete

func (r Redis) Delete(keys ...string) int64

func (Redis) Get

func (r Redis) Get(key string) any

func (Redis) Scan

func (r Redis) Scan(key string) []string

func (Redis) Set

func (r Redis) Set(key string, data any) bool

func (Redis) SetWithExp

func (r Redis) SetWithExp(key string, data any, exp time.Duration) bool

Jump to

Keyboard shortcuts

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