android 微信是如何实现即时更新好友头像的
迷茫
迷茫 2017-04-17 17:58:48
0
5
1670

微信好友的头像肯定是做缓存的,那么好友头像修改后,用户这边是如何实现立即就能看到修改后的头像的呢?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(5)
左手右手慢动作

If you want to achieve real-time updates: you need to use push. After A modifies his avatar, he notifies the server, and the server then sends a push notification to A's friends to update A's avatar.

迷茫

The first thing to pull must be the avatar URL. The local cache is based on the URL. Every time the local cache pulls the avatar URL and then loads it through the loading module, it will judge whether the currently cached image is consistent with this URL. Otherwise, it will be inconsistent. Download through the new url.

PHPzhong

Save a field in the database: the last avatar modification time.

刘奇

Let’s speculate, the process in brackets is a wild guess:
User A uploads a new avatar → the server processes the new avatar → stores the new avatar URL in a field in the user table, recording the change time (→ synchronizes the avatar to CDN → updates The avatar URL field of the user table records the change time) → the server sends a push to the online client → the client updates the avatar.

左手右手慢动作

Take a guess, you can set a identification field, the default is 0, set it to 1 when the user updates the avatar, and push this identification at the same time when pushing messages or regular synchronization.
While processing messages or regularly synchronizing contact information, the mobile phone determines this identifier. If the identifier is 1, it means that the friend has uploaded a new avatar. At this time, a GET request is made to pull the new avatar and cache it locally, and at the same time, the server-side identifier is updated. 0, to prevent repeated requests for avatars during the next synchronization.
(PS: Just some personal thoughts.)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template