redmon

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 12 Imported by: 2

README

redmon

redis cached mongodb based nosql database

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("redmon: already exists")
	ErrNotExists     = errors.New("redmon: not exists")
	ErrMailBoxFull   = errors.New("redmon: mail box full")
)

Functions

This section is empty.

Types

type Client

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

客户端

func NewClient

func NewClient(rdb redis.Client, mdb *mongo.Client, opts ...Option) *Client

func (*Client) Add

func (cli *Client) Add(ctx context.Context, key, val string) (err error)

新增数据,如果指定数据不在缓存里会自动从DB加载 如果指定数据已存在返回ErrAlreadyExists

func (*Client) Get

func (cli *Client) Get(ctx context.Context, key string, opts ...GetOption) (rev int64, val string, err error)

获取数据,如果指定数据不在缓存里会自动从DB加载

func (*Client) List

func (cli *Client) List(ctx context.Context, key string) (_ []*Mail, err error)

获取邮箱数据,如果指定数据不在缓存里会自动从DB加载

func (*Client) Pull

func (cli *Client) Pull(ctx context.Context, key string, ids ...int64) (pulled []int64, err error)

删除邮件,如果指定数据不在缓存里会自动从DB加载

func (*Client) Push

func (cli *Client) Push(ctx context.Context, key, val string, opts ...PushOption) (id int64, err error)

添加邮件,如果指定数据不在缓存里会自动从DB加载

func (*Client) Set

func (cli *Client) Set(ctx context.Context, key, val string) (rev int64, err error)

设置数据,如果指定数据不在缓存里会自动从DB加载 缓存中的脏数据由Sync异步回写到DB

func (*Client) Sync

func (cli *Client) Sync(ctx context.Context)

////////////////////////////////////////////////////////////////////////////// Syncing //////////////////////////////////////////////////////////////////////////////

type GetOption

type GetOption interface {
	// contains filtered or unexported methods
}

Client.Get Options

func AddIfNotExists

func AddIfNotExists(v string) GetOption

type KeyMappingFunc

type KeyMappingFunc func(key string) (db, collection, _id string)

Redis(key) -> Mongo(db,collection,_id)

type Mail

type Mail struct {
	// auto-generated seq to identify a mail
	Id int64 `msgpack:"id"`
	// mail payload
	Val string `msgpack:"val"`
}

邮件

func (Mail) GetImportance

func (m Mail) GetImportance() uint8

type OnSyncFailFunc

type OnSyncFailFunc func(err error) time.Duration

同步失败回调函数

type OnSyncIdleFunc

type OnSyncIdleFunc func() time.Duration

同步空闲回调函数

type OnSyncSaveFunc

type OnSyncSaveFunc func(key string) time.Duration

同步成功回调函数

type Option

type Option interface {
	// contains filtered or unexported methods
}

Client Options

func OnSyncFail

func OnSyncFail(f OnSyncFailFunc) Option

func OnSyncIdle

func OnSyncIdle(f OnSyncIdleFunc) Option

func OnSyncSave

func OnSyncSave(f OnSyncSaveFunc) Option

func WithKeyMap

func WithKeyMap(f KeyMappingFunc) Option

type PushOption

type PushOption interface {
	// contains filtered or unexported methods
}

Client.Push Options

func WithCapacity

func WithCapacity(v uint16) PushOption

func WithImportance

func WithImportance(v uint8) PushOption

func WithRing

func WithRing() PushOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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