Documentation ¶
Index ¶
- type Cache
- type Item
- func (i *Item) Array() ([]interface{}, error)
- func (i *Item) Bool() (bool, error)
- func (i *Item) Bytes() ([]byte, error)
- func (i *Item) Float64() (float64, error)
- func (i *Item) Int() (int, error)
- func (i *Item) Int64() (int64, error)
- func (i *Item) Map() (map[string]interface{}, error)
- func (i *Item) MustArray(args ...[]interface{}) []interface{}
- func (i *Item) MustBool(args ...bool) bool
- func (i *Item) MustFloat64(args ...float64) float64
- func (i *Item) MustInt(args ...int) int
- func (i *Item) MustInt64(args ...int64) int64
- func (i *Item) MustMap(args ...map[string]interface{}) map[string]interface{}
- func (i *Item) MustString(args ...string) string
- func (i *Item) MustUint64(args ...uint64) uint64
- func (i *Item) String() (string, error)
- func (i *Item) StringArray() ([]string, error)
- func (i *Item) Uint64() (uint64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a synchronised map of items that auto-expire once stale
func NewCacheEx ¶
NewCacheEx is a helper to create instance of the Cache struct with specified cleanup interval
func (*Cache) Count ¶
Count returns the number of items in the cache (helpful for tracking memory leaks)
func (*Cache) Get ¶
Get is a thread-safe way to lookup items Every lookup, also touches the item, hence extending it's life
func (*Cache) SetIfNotExist ¶
SetIfNotExist is a thread-safe way to add new items to the map. Add successfully only when item is not exists.
type Item ¶
Item represents a record in the cache map
func (*Item) MustArray ¶
func (i *Item) MustArray(args ...[]interface{}) []interface{}
MustArray guarantees the return of a `[]interface{}` (with optional default)
useful when you want to interate over array values in a succinct manner:
for i, v := range js.Get("results").MustArray() { fmt.Println(i, v) }
func (*Item) MustBool ¶
MustBool guarantees the return of a `bool` (with optional default)
useful when you explicitly want a `bool` in a single value return context:
myFunc(js.Get("param1").MustBool(), js.Get("optional_param").MustBool(true))
func (*Item) MustFloat64 ¶
MustFloat64 guarantees the return of a `float64` (with optional default)
useful when you explicitly want a `float64` in a single value return context:
myFunc(js.Get("param1").MustFloat64(), js.Get("optional_param").MustFloat64(5.150))
func (*Item) MustInt ¶
MustInt guarantees the return of an `int` (with optional default)
useful when you explicitly want an `int` in a single value return context:
myFunc(js.Get("param1").MustInt(), js.Get("optional_param").MustInt(5150))
func (*Item) MustInt64 ¶
MustInt64 guarantees the return of an `int64` (with optional default)
useful when you explicitly want an `int64` in a single value return context:
myFunc(js.Get("param1").MustInt64(), js.Get("optional_param").MustInt64(5150))
func (*Item) MustMap ¶
MustMap guarantees the return of a `map[string]interface{}` (with optional default)
useful when you want to interate over map values in a succinct manner:
for k, v := range js.Get("dictionary").MustMap() { fmt.Println(k, v) }
func (*Item) MustString ¶
MustString guarantees the return of a `string` (with optional default)
useful when you explicitly want a `string` in a single value return context:
myFunc(js.Get("param1").MustString(), js.Get("optional_param").MustString("my_default"))
func (*Item) MustUint64 ¶
MustUInt64 guarantees the return of an `uint64` (with optional default)
useful when you explicitly want an `uint64` in a single value return context:
myFunc(js.Get("param1").MustUint64(), js.Get("optional_param").MustUint64(5150))
func (*Item) StringArray ¶
StringArray type asserts to an `array` of `string`