func (r *Store) Len() int {
	args := *r
	return len(args)
}
Len returns the full length of the entries.
package memstore
import (
	"reflect"
	"strconv"
	"strings"
	"github.com/kataras/iris/core/errors"
)
type (
	Entry struct {
		Key       string
		ValueRaw  interface{}
		immutable bool  
	}
	Store []Entry
)
func (e Entry) GetByKindOrNil(k reflect.Kind) interface{} {
	switch k {
	case reflect.String:
		v := e.StringDefault("__$nf")
		if v == "__$nf" {
			return nil
		}
		return v
	case reflect.Int:
		v, err := e.IntDefault(-1)
		if err != nil || v == -1 {
			return nil
		}
		return v
	case reflect.Int64:
		v, err := e.Int64Default(-1)
		if err != nil || v == -1 {
			return nil
		}
		return v
	case reflect.Bool:
		v, err := e.BoolDefault(false)
		if err != nil {
			return nil
		}
		return v
	default:
		return e.ValueRaw
	}
}
func (e Entry) StringDefault(def string) string {
	v := e.ValueRaw
	if vString, ok := v.(string); ok {
		return vString
	}
	return def
}
func (e Entry) String() string {
	return e.StringDefault("")
}
func (e Entry) StringTrim() string {
	return strings.TrimSpace(e.String())
}
var errFindParse = errors.New("unable to find the %s with key: %s")
func (e Entry) IntDefault(def int) (int, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("int", e.Key)
	}
	if vint, ok := v.(int); ok {
		return vint, nil
	} else if vstring, sok := v.(string); sok && vstring != "" {
		vint, err := strconv.Atoi(vstring)
		if err != nil {
			return def, err
		}
		return vint, nil
	}
	return def, errFindParse.Format("int", e.Key)
}
func (e Entry) Int64Default(def int64) (int64, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("int64", e.Key)
	}
	if vint64, ok := v.(int64); ok {
		return vint64, nil
	}
	if vint, ok := v.(int); ok {
		return int64(vint), nil
	}
	if vstring, sok := v.(string); sok {
		return strconv.ParseInt(vstring, 10, 64)
	}
	return def, errFindParse.Format("int64", e.Key)
}
func (e Entry) Float64Default(def float64) (float64, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("float64", e.Key)
	}
	if vfloat32, ok := v.(float32); ok {
		return float64(vfloat32), nil
	}
	if vfloat64, ok := v.(float64); ok {
		return vfloat64, nil
	}
	if vint, ok := v.(int); ok {
		return float64(vint), nil
	}
	if vstring, sok := v.(string); sok {
		vfloat64, err := strconv.ParseFloat(vstring, 64)
		if err != nil {
			return def, err
		}
		return vfloat64, nil
	}
	return def, errFindParse.Format("float64", e.Key)
}
func (e Entry) Float32Default(key string, def float32) (float32, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("float32", e.Key)
	}
	if vfloat32, ok := v.(float32); ok {
		return vfloat32, nil
	}
	if vfloat64, ok := v.(float64); ok {
		return float32(vfloat64), nil
	}
	if vint, ok := v.(int); ok {
		return float32(vint), nil
	}
	if vstring, sok := v.(string); sok {
		vfloat32, err := strconv.ParseFloat(vstring, 32)
		if err != nil {
			return def, err
		}
		return float32(vfloat32), nil
	}
	return def, errFindParse.Format("float32", e.Key)
}
func (e Entry) BoolDefault(def bool) (bool, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("bool", e.Key)
	}
	if vBoolean, ok := v.(bool); ok {
		return vBoolean, nil
	}
	if vString, ok := v.(string); ok {
		b, err := strconv.ParseBool(vString)
		if err != nil {
			return def, err
		}
		return b, nil
	}
	if vInt, ok := v.(int); ok {
		if vInt == 1 {
			return true, nil
		}
		return false, nil
	}
	return def, errFindParse.Format("bool", e.Key)
}
func (e Entry) Value() interface{} {
	if e.immutable {
		vv := reflect.Indirect(reflect.ValueOf(e.ValueRaw))
		if vv.Type().Kind() == reflect.Slice {
			newSlice := reflect.MakeSlice(vv.Type(), vv.Len(), vv.Cap())
			reflect.Copy(newSlice, vv)
			return newSlice.Interface()
		}
		if vv.Type().Kind() == reflect.Map {
			newMap := reflect.MakeMap(vv.Type())
			for _, k := range vv.MapKeys() {
				newMap.SetMapIndex(k, vv.MapIndex(k))
			}
			return newMap.Interface()
		}
		return vv.Interface()
	}
	return e.ValueRaw
}
func (r *Store) Save(key string, value interface{}, immutable bool) (Entry, bool) {
	args := *r
	n := len(args)
	for i := 0; i < n; i++ {
		kv := &args[i]
		if kv.Key == key {
			if immutable && kv.immutable {
				kv.ValueRaw = value
				kv.immutable = immutable
			} else if kv.immutable == false {
				kv.ValueRaw = value
				kv.immutable = immutable
			}
			return *kv, false
		}
	}
	c := cap(args)
	if c > n {
		args = args[:n+1]
		kv := &args[n]
		kv.Key = key
		kv.ValueRaw = value
		kv.immutable = immutable
		*r = args
		return *kv, true
	}
	kv := Entry{
		Key:       key,
		ValueRaw:  value,
		immutable: immutable,
	}
	*r = append(args, kv)
	return kv, true
}
func (r *Store) Set(key string, value interface{}) (Entry, bool) {
	return r.Save(key, value, false)
}
func (r *Store) SetImmutable(key string, value interface{}) (Entry, bool) {
	return r.Save(key, value, true)
}
func (r *Store) GetEntry(key string) *Entry {
	args := *r
	n := len(args)
	for i := 0; i < n; i++ {
		kv := &args[i]
		if kv.Key == key {
			return kv
		}
	}
	return nil
}
func (r *Store) GetDefault(key string, def interface{}) interface{} {
	v := r.GetEntry(key)
	if v == nil || v.ValueRaw == nil {
		return def
	}
	vv := v.Value()
	if vv == nil {
		return def
	}
	return vv
}
func (r *Store) Get(key string) interface{} {
	return r.GetDefault(key, nil)
}
func (r *Store) Visit(visitor func(key string, value interface{})) {
	args := *r
	for i, n := 0, len(args); i < n; i++ {
		kv := args[i]
		visitor(kv.Key, kv.Value())
	}
}
func (r *Store) GetStringDefault(key string, def string) string {
	v := r.GetEntry(key)
	if v == nil {
		return def
	}
	return v.StringDefault(def)
}
func (r *Store) GetString(key string) string {
	return r.GetStringDefault(key, "")
}
func (r *Store) GetStringTrim(name string) string {
	return strings.TrimSpace(r.GetString(name))
}
func (r *Store) GetInt(key string) (int, error) {
	v := r.GetEntry(key)
	if v == nil {
		return 0, errFindParse.Format("int", key)
	}
	return v.IntDefault(-1)
}
func (r *Store) GetIntDefault(key string, def int) int {
	if v, err := r.GetInt(key); err == nil {
		return v
	}
	return def
}
func (r *Store) GetInt64(key string) (int64, error) {
	v := r.GetEntry(key)
	if v == nil {
		return -1, errFindParse.Format("int64", key)
	}
	return v.Int64Default(-1)
}
func (r *Store) GetInt64Default(key string, def int64) int64 {
	if v, err := r.GetInt64(key); err == nil {
		return v
	}
	return def
}
func (r *Store) GetFloat64(key string) (float64, error) {
	v := r.GetEntry(key)
	if v == nil {
		return -1, errFindParse.Format("float64", key)
	}
	return v.Float64Default(-1)
}
func (r *Store) GetFloat64Default(key string, def float64) float64 {
	if v, err := r.GetFloat64(key); err == nil {
		return v
	}
	return def
}
func (r *Store) GetBool(key string) (bool, error) {
	v := r.GetEntry(key)
	if v == nil {
		return false, errFindParse.Format("bool", key)
	}
	return v.BoolDefault(false)
}
func (r *Store) GetBoolDefault(key string, def bool) bool {
	if v, err := r.GetBool(key); err == nil {
		return v
	}
	return def
}
func (r *Store) Remove(key string) bool {
	args := *r
	n := len(args)
	for i := 0; i < n; i++ {
		kv := &args[i]
		if kv.Key == key {
			args = append(args[:i], args[i+1:]...)
			*r = args
			return true
		}
	}
	return false
}
func (r *Store) Reset() {
	*r = (*r)[0:0]
}