diff options
Diffstat (limited to 'telegram/cache/cache.go')
-rw-r--r-- | telegram/cache/cache.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/telegram/cache/cache.go b/telegram/cache/cache.go index 3d9608d..c4a59bf 100644 --- a/telegram/cache/cache.go +++ b/telegram/cache/cache.go @@ -19,9 +19,11 @@ type Cache struct { chats map[int64]*client.Chat users map[int64]*client.User statuses map[int64]*Status + capsVers map[int64]string chatsLock sync.Mutex usersLock sync.Mutex statusesLock sync.Mutex + capsVersLock sync.Mutex } // NewCache initializes a cache @@ -106,6 +108,15 @@ func (cache *Cache) GetStatus(id int64) (*Status, bool) { return status, ok } +// GetCapsVer retrieves capabilities verification string by id if it's present in the cache +func (cache *Cache) GetCapsVer(id int64) (string, bool) { + cache.capsVersLock.Lock() + defer cache.capsVersLock.Unlock() + + ver, ok := cache.capsVers[id] + return ver, ok +} + // SetChat stores a chat in the cache func (cache *Cache) SetChat(id int64, chat *client.Chat) { cache.chatsLock.Lock() @@ -133,3 +144,11 @@ func (cache *Cache) SetStatus(id int64, show string, status string) { Description: status, } } + +// SetCapsVer stores a capabilities verification string in the cache +func (cache *Cache) SetCapsVer(id int64, ver string) { + cache.capsVersLock.Lock() + defer cache.capsVersLock.Unlock() + + cache.capsVers[id] = ver +} |