remon

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

remon

redis cached mongodb based nosql database

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Client added in v0.1.4

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

客户端

func NewClient added in v0.1.4

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

func (*Client) Add added in v0.1.4

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

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

func (*Client) Get added in v0.1.4

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

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

func (*Client) List added in v0.1.8

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

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

func (*Client) Pull added in v0.1.8

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

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

func (*Client) Push added in v0.1.8

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

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

func (*Client) Set added in v0.1.4

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

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

func (*Client) Sync added in v0.1.8

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

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

type GetOption added in v0.1.4

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

Client.Get Options

func AddIfNotExists added in v0.1.8

func AddIfNotExists(v string) GetOption

type KeyMappingFunc added in v0.1.8

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

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

type Mail added in v0.1.4

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

邮件

func (Mail) GetImportance added in v0.1.9

func (m Mail) GetImportance() uint8

type OnSyncFailFunc added in v0.1.8

type OnSyncFailFunc func(err error) time.Duration

同步失败回调函数

type OnSyncIdleFunc added in v0.1.4

type OnSyncIdleFunc func() time.Duration

同步空闲回调函数

type OnSyncSaveFunc added in v0.1.4

type OnSyncSaveFunc func(key string) time.Duration

同步成功回调函数

type Option

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

Client Options

func OnSyncFail added in v0.1.8

func OnSyncFail(f OnSyncFailFunc) Option

func OnSyncIdle added in v0.1.4

func OnSyncIdle(f OnSyncIdleFunc) Option

func OnSyncSave added in v0.1.4

func OnSyncSave(f OnSyncSaveFunc) Option

func WithKeyMap added in v0.1.4

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 added in v0.1.8

func WithImportance(v uint8) PushOption

func WithRing added in v0.1.8

func WithRing() PushOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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