datax

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataContext

type DataContext interface {
	Set(key string, value interface{})
	Get(key string) (value interface{}, exists bool)
	MustGet(key string) interface{}
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetInt64(key string) int64
	GetFloat64(key string) float64
	GetTime(key string) time.Time
	GetDuration(key string) time.Duration
	GetStringSlice(key string) []string
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringMapStringSlice(key string) map[string][]string
}

DataContext interface the extend of contextx.Context.Value(key string) (value interface{})

type MemoryContext

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

MemoryContext gstore data tor memory

func NewMemoryContext

func NewMemoryContext() *MemoryContext

NewMemoryContext new one

func (*MemoryContext) Get

func (c *MemoryContext) Get(key string) (value interface{}, exists bool)

Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)

func (*MemoryContext) GetBool

func (c *MemoryContext) GetBool(key string) (b bool)

GetBool returns the value associated with the key as a boolean.

func (*MemoryContext) GetDuration

func (c *MemoryContext) GetDuration(key string) (d time.Duration)

GetDuration returns the value associated with the key as a duration.

func (*MemoryContext) GetFloat64

func (c *MemoryContext) GetFloat64(key string) (f64 float64)

GetFloat64 returns the value associated with the key as a float64.

func (*MemoryContext) GetInt

func (c *MemoryContext) GetInt(key string) (i int)

GetInt returns the value associated with the key as an integer.

func (*MemoryContext) GetInt64

func (c *MemoryContext) GetInt64(key string) (i64 int64)

GetInt64 returns the value associated with the key as an integer.

func (*MemoryContext) GetString

func (c *MemoryContext) GetString(key string) (s string)

GetString returns the value associated with the key as a string.

func (*MemoryContext) GetStringMap

func (c *MemoryContext) GetStringMap(key string) (sm map[string]interface{})

GetStringMap returns the value associated with the key as a map of interfaces.

func (*MemoryContext) GetStringMapString

func (c *MemoryContext) GetStringMapString(key string) (sms map[string]string)

GetStringMapString returns the value associated with the key as a map of strings.

func (*MemoryContext) GetStringMapStringSlice

func (c *MemoryContext) GetStringMapStringSlice(key string) (smss map[string][]string)

GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.

func (*MemoryContext) GetStringSlice

func (c *MemoryContext) GetStringSlice(key string) (ss []string)

GetStringSlice returns the value associated with the key as a slice of strings.

func (*MemoryContext) GetTime

func (c *MemoryContext) GetTime(key string) (t time.Time)

GetTime returns the value associated with the key as time.

func (*MemoryContext) MustGet

func (c *MemoryContext) MustGet(key string) interface{}

MustGet returns the value for the given key if it exists, otherwise it panics.

func (*MemoryContext) Set

func (c *MemoryContext) Set(key string, value interface{})

Set is used to gstore a new key/value pair exclusively for this contextx. It also lazy initializes c.data if it was not used previously.

Jump to

Keyboard shortcuts

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