Memory cleanup for caching
Remove cached deleted messages from dialogs Comment out unused variables
This commit is contained in:
parent
9773e87e96
commit
76dbe45ad8
@ -14539,10 +14539,10 @@ void ContactsManager::memory_cleanup() {
|
||||
{
|
||||
auto it = users_.begin();
|
||||
while (it != users_.end()) {
|
||||
auto &user = it->second;
|
||||
//auto &user = it->second;
|
||||
auto user_id = it->first;
|
||||
|
||||
auto is_invalid = it->first.get_time() > user_ttl;
|
||||
auto is_invalid = user_id.get_time() > user_ttl;
|
||||
|
||||
if (is_invalid) {
|
||||
user_id.reset_time();
|
||||
@ -14572,10 +14572,10 @@ void ContactsManager::memory_cleanup() {
|
||||
{
|
||||
auto it = chats_.begin();
|
||||
while (it != chats_.end()) {
|
||||
auto &chat = it->second;
|
||||
//auto &chat = it->second;
|
||||
auto chat_id = it->first;
|
||||
|
||||
auto is_invalid = it->first.get_time() > chat_ttl;
|
||||
auto is_invalid = chat_id.get_time() > chat_ttl;
|
||||
|
||||
if (is_invalid) {
|
||||
chat_id.reset_time();
|
||||
@ -14600,10 +14600,10 @@ void ContactsManager::memory_cleanup() {
|
||||
{
|
||||
auto it = channels_.begin();
|
||||
while (it != channels_.end()) {
|
||||
auto &channel = it->second;
|
||||
//auto &channel = it->second;
|
||||
auto channel_id = it->first;
|
||||
|
||||
auto is_invalid = it->first.get_time() > chat_ttl;
|
||||
auto is_invalid = channel_id.get_time() > chat_ttl;
|
||||
|
||||
if (is_invalid) {
|
||||
channel_id.reset_time();
|
||||
|
@ -5732,6 +5732,23 @@ tl_object_ptr<telegram_api::InputMessage> MessagesManager::get_input_message(Mes
|
||||
return make_tl_object<telegram_api::inputMessageID>(message_id.get_server_message_id().get());
|
||||
}
|
||||
|
||||
|
||||
void MessagesManager::memory_cleanup() {
|
||||
/* CLEAR DELETED MESSAGES CACHE */
|
||||
{
|
||||
auto it = dialogs_.begin();
|
||||
while (it != dialogs_.end()) {
|
||||
auto &dialog = it->second;
|
||||
|
||||
auto &deleted_message_ids = dialog->deleted_message_ids;
|
||||
deleted_message_ids.clear();
|
||||
deleted_message_ids.rehash(0);
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputPeer> MessagesManager::get_input_peer(DialogId dialog_id,
|
||||
AccessRights access_rights) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
|
@ -190,6 +190,8 @@ class MessagesManager : public Actor {
|
||||
MessagesManager &operator=(MessagesManager &&) = delete;
|
||||
~MessagesManager() override;
|
||||
|
||||
void memory_cleanup();
|
||||
|
||||
static vector<MessageId> get_message_ids(const vector<int64> &input_message_ids);
|
||||
|
||||
static vector<int32> get_server_message_ids(const vector<MessageId> &message_ids);
|
||||
|
@ -5234,6 +5234,7 @@ void Td::on_request(uint64 id, td_api::getDatabaseStatistics &request) {
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::optimizeStorage &request) {
|
||||
messages_manager_->memory_cleanup();
|
||||
contacts_manager_->memory_cleanup();
|
||||
web_pages_manager_->memory_cleanup();
|
||||
stickers_manager_->memory_cleanup();
|
||||
|
Loading…
Reference in New Issue
Block a user