mirror of
https://github.com/wonli/aqi.git
synced 2024-06-28 09:57:05 +08:00
23 lines
352 B
Go
23 lines
352 B
Go
|
package ws
|
||
|
|
||
|
func (c *Client) SetKey(key string, value any) {
|
||
|
c.mu.Lock()
|
||
|
defer c.mu.Unlock()
|
||
|
if c.Keys == nil {
|
||
|
c.Keys = make(map[string]any)
|
||
|
}
|
||
|
|
||
|
c.Keys[key] = value
|
||
|
}
|
||
|
|
||
|
func (c *Client) GetKey(key string) *Value {
|
||
|
c.mu.RLock()
|
||
|
defer c.mu.RUnlock()
|
||
|
value, exists := c.Keys[key]
|
||
|
if !exists {
|
||
|
return &Value{}
|
||
|
}
|
||
|
|
||
|
return &Value{data: value}
|
||
|
}
|