i wanted to add full cahce but i dont have time :(
This commit is contained in:
@@ -22,6 +22,26 @@ func CacheGetClientById(id uint32) (*Client, error) {
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func CacheGetIdByName(name string) (uint32, error) {
|
||||
client, err := CacheGetClientByName(name)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return client.Id, nil
|
||||
}
|
||||
|
||||
func CacheGetClientByName(name string) (*Client, error) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
for _, client := range CacheClients {
|
||||
if client.Name == name {
|
||||
return client, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("client %s not found", name)
|
||||
}
|
||||
|
||||
func CacheSetClient(client *Client) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user