Documentation
¶
Overview ¶
Package peercache provides a file-backed implementation of peers.Storage.
StringSession/FileStorage sessions keep no entity cache, so resolved access-hashes would be lost between CLI invocations. This storage persists them as JSON in the session directory, keyed per account, so peer resolution is cheap and survives restarts.
Index ¶
- Constants
- type Storage
- func (s *Storage) Find(_ context.Context, key peers.Key) (peers.Value, bool, error)
- func (s *Storage) FindPhone(_ context.Context, phone string) (peers.Key, peers.Value, bool, error)
- func (s *Storage) GetContactsHash(_ context.Context) (int64, error)
- func (s *Storage) Kind(id int64) (string, bool)
- func (s *Storage) Save(_ context.Context, key peers.Key, value peers.Value) error
- func (s *Storage) SaveContactsHash(_ context.Context, hash int64) error
- func (s *Storage) SavePhone(_ context.Context, phone string, key peers.Key) error
Constants ¶
const ( KindUser = "user" KindChat = "chat" KindChannel = "channel" )
Peer kinds returned by Kind, matching the type names used in CLI output.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is a JSON-file-backed peers.Storage.
func (*Storage) GetContactsHash ¶
GetContactsHash implements peers.Storage.
func (*Storage) Kind ¶ added in v0.8.0
Kind reports the cached peer kind ("user", "chat" or "channel") for a numeric id, if the peer has been seen before (e.g. via `tg chats list`). Users and channels are checked before chats so a populated access hash wins.
gotd's peers.Storage keys entries as "<prefix>:<id>"; the prefixes are unexported there (telegram/peers/storage.go), so we mirror them here.
func (*Storage) SaveContactsHash ¶
SaveContactsHash implements peers.Storage.