-
Notifications
You must be signed in to change notification settings - Fork 5
/
get.go
27 lines (25 loc) · 924 Bytes
/
get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package hermes
// Get is a method of the Cache struct that retrieves the value associated with the given key from the cache.
// This method is thread-safe.
//
// Parameters:
// - key: A string representing the key to retrieve the value for.
//
// Returns:
// - A map[string]any representing the value associated with the given key in the cache.
func (c *Cache) Get(key string) map[string]any {
c.mutex.RLock()
defer c.mutex.RUnlock()
return c.get(key)
}
// get is a method of the Cache struct that retrieves the value associated with the given key from the cache.
// This method is not thread-safe and should only be called from an exported function.
//
// Parameters:
// - key: A string representing the key to retrieve the value for.
//
// Returns:
// - A map[string]any representing the value associated with the given key in the cache.
func (c *Cache) get(key string) map[string]any {
return c.data[key]
}