mirror of
https://github.com/foomo/posh.git
synced 2025-10-16 12:45:38 +00:00
29 lines
543 B
Go
29 lines
543 B
Go
package cache
|
|
|
|
type MemoryCache map[string]MemoryNamespace
|
|
|
|
func (c MemoryCache) Clear(namespace string) {
|
|
if namespace == "" {
|
|
for key := range c {
|
|
delete(c, key)
|
|
}
|
|
} else if _, ok := c[namespace]; ok {
|
|
delete(c, namespace)
|
|
}
|
|
}
|
|
|
|
func (c MemoryCache) Get(namespace string) Namespace {
|
|
if _, ok := c[namespace]; !ok {
|
|
c[namespace] = MemoryNamespace{}
|
|
}
|
|
return c[namespace]
|
|
}
|
|
|
|
func (c MemoryCache) List() map[string]Namespace {
|
|
ret := map[string]Namespace{}
|
|
for s, namespace := range c {
|
|
ret[s] = namespace
|
|
}
|
|
return ret
|
|
}
|