mirror of
https://github.com/kataras/iris.git
synced 2026-01-27 13:55:56 +00:00
minor
Former-commit-id: 4c71a275f3e10dd0ce77bf5723c370be765663ab
This commit is contained in:
@@ -815,6 +815,19 @@ func (r *Store) Get(key string) interface{} {
|
||||
return r.GetDefault(key, nil)
|
||||
}
|
||||
|
||||
// GetOrSet is like `GetDefault` but it accepts a function which is
|
||||
// fired and its result is used to `Set` if
|
||||
// the "key" was not found or its value is nil.
|
||||
func (r *Store) GetOrSet(key string, setFunc func() interface{}) interface{} {
|
||||
if v, ok := r.GetEntry(key); ok && v.ValueRaw != nil {
|
||||
return v.Value()
|
||||
}
|
||||
|
||||
value := setFunc()
|
||||
r.Set(key, value)
|
||||
return value
|
||||
}
|
||||
|
||||
// Visit accepts a visitor which will be filled
|
||||
// by the key-value objects.
|
||||
func (r *Store) Visit(visitor func(key string, value interface{})) {
|
||||
|
||||
Reference in New Issue
Block a user