mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2025-03-15 13:22:43 +01:00
Update content of files
This commit is contained in:
parent
b2218d784c
commit
4605235e8c
2 changed files with 4 additions and 1 deletions
|
@ -68,6 +68,7 @@
|
|||
<li>Clarified <a href="/api/updates#subscribing-to-updates">which updates may be accepted from not yet logged sessions »</a>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Clarified that the <a href="/api/offsets#hash-generation">hash generation algorithm used for caching</a> uses the unsigned right shift operator and can also accept strings in the ID array. </li>
|
||||
</ul>
|
||||
<p>The following new features were added:</p>
|
||||
<ul>
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
</ul>
|
||||
<h3><a class="anchor" href="#hash-generation" id="hash-generation" name="hash-generation"><i class="anchor-icon"></i></a>Hash generation</h3>
|
||||
<p>To further reduce the result subset, there is a mechanism to avoid fetching data if the resulting list hasn't changed from the one stored on client, similar to <a href="https://en.wikipedia.org/wiki/HTTP_ETag">ETag</a>.</p>
|
||||
<p>When the client has cached results for API request, it can calculate the <code>hash</code> value for it by taking the result IDs (message IDs or other fields with name <code>id</code>) and using them to compute a 64-bit hash with the following algorithm:</p>
|
||||
<p>When the client has cached results for API request, it can calculate the <code>hash</code> value for it by taking the result IDs (message IDs or other fields with name <code>id</code>, or some extra fields in some cases) and using them to compute a 64-bit hash with the following algorithm:</p>
|
||||
<pre><code># Here, ^ indicates a bitwise XOR
|
||||
|
||||
hash = 0
|
||||
|
@ -88,6 +88,8 @@ for id in ids:
|
|||
hash = hash ^ (hash << 35)
|
||||
hash = hash ^ (hash >> 4)
|
||||
hash = hash + id</code></pre>
|
||||
<p>The <code>>></code> operator is the unsigned right shift operator. </p>
|
||||
<p>Note: in some cases, the <code>ids</code> array passed to the algorithm must contain strings (i.e. the shortcut name in business shortcuts, and so on...), in which case they must be transformed to longs by taking the first 8 bytes of the MD5 hash of the string (<strong>not</strong> in hex form) and treating it as a big-endian 64-bit long. </p>
|
||||
<p>In some cases, if the result container already has a <code>hash</code> field, that can be used instead. </p>
|
||||
<p>When the client passes a correct value, the API will return one of <code>*NotModified</code> constructors, e.g. <a href="/constructor/messages.messagesNotModified">messages.messagesNotModified</a> instead of the actual results.</p>
|
||||
<h3><a class="anchor" href="#example-methods" id="example-methods" name="example-methods"><i class="anchor-icon"></i></a>Example methods</h3>
|
||||
|
|
Loading…
Add table
Reference in a new issue