{
    "componentChunkName": "component---src-templates-doc-page-js",
    "path": "/docs/en/JS_API/overflow_session_client_data/",
    "result": {"data":{"site":{"siteMetadata":{"title":"Gatsby-doc-engine"}},"markdownRemark":{"id":"ca6072bb-1382-5cc4-b1f5-9cc427f87f33","excerpt":"client object data overflow processing in the script!> There is a limit on the amount of data stored in the  and  objects. If this limit is exceeded, the…","html":"<h1><span class=\"math math-inline\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>s</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>a</mi><mi>n</mi><mi>d</mi></mrow><annotation encoding=\"application/x-tex\">session and </annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.69444em;vertical-align:0em;\"></span><span class=\"mord mathnormal\">s</span><span class=\"mord mathnormal\">e</span><span class=\"mord mathnormal\">s</span><span class=\"mord mathnormal\">s</span><span class=\"mord mathnormal\">i</span><span class=\"mord mathnormal\">o</span><span class=\"mord mathnormal\">n</span><span class=\"mord mathnormal\">a</span><span class=\"mord mathnormal\">n</span><span class=\"mord mathnormal\">d</span></span></span></span></span>client object data overflow processing in the script</h1>\n<hr>\n<p class='tip'>There is a limit on the amount of data stored in the <code class=\"language-text\">$session</code> and <code class=\"language-text\">$client</code> objects. If this limit is exceeded, the current script is aborted and the bot stops responding to the client.</p>\n<ul>\n<li><a href=\"/1.10.3/docs/en/JS_API/variables/client\"><code class=\"language-text\">$client</code> is the object used to store permanent client data</a>.</li>\n<li><a href=\"/1.10.3/docs/en/JS_API/variables/session\"><code class=\"language-text\">$session</code> is the object used to store session data</a>.</li>\n</ul>\n<p>You need to handle the <code class=\"language-text\">$session</code> and <code class=\"language-text\">$client</code> object data overflow events in your script to prevent it from being aborted.</p>\n</br>\n<h4>Limits</h4>\n<p>The following limits are set by default:</p>\n<ul>\n<li><code class=\"language-text\">soft</code>: 100 KB;</li>\n<li><code class=\"language-text\">hard</code>: 1000 KB.</li>\n</ul>\n<p class='warn'>Please note that these limits are set per object. This means that 100 KB of data are available for the <code class=\"language-text\">$client</code> object under the <code class=\"language-text\">soft</code> limit and 100 KB more data are available for the <code class=\"language-text\">$session</code> object.</p>\n</br>\n<h4>Overflow handling</h4>\n<p>If the <code class=\"language-text\">soft</code> limit is reached but the <code class=\"language-text\">hard</code> limit is not exceeded, data will continue to be saved to the <code class=\"language-text\">$session</code> and <code class=\"language-text\">$client</code> objects. The script will receive the following events when the <code class=\"language-text\">soft</code> limit is reached: <code class=\"language-text\">event: sessionDataSoftLimitExceeded</code> and <code class=\"language-text\">event: clientDataSoftLimitExceeded</code>.</p>\n<p>If the new data exceed the <code class=\"language-text\">hard</code> limit, they are not saved to the <code class=\"language-text\">$session</code> and <code class=\"language-text\">$client</code> objects. The script will receive the following events when the <code class=\"language-text\">hard</code> limit is reached: <code class=\"language-text\">event: sessionDataHardLimitExceeded</code> and <code class=\"language-text\">event: clientDataHardLimitExceeded</code>.</p>\n<p>Example of data overflow handling in the script:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">theme:</span> /\n\n    <span class=\"token keyword\">state:</span>\n        <span class=\"token storageType\">q:</span> * *start\n        <span class=\"token variableParameter\">go!:</span> /start\n\n    <span class=\"token keyword\">state:</span> start\n        <span class=\"token storageType\">q!:</span> *\n        <span class=\"token variableParameter\">script:</span>\n            $session.text = $parseTree.text    <span class=\"token comment\">// save session data</span>\n        <span class=\"token variableParameter\">a:</span> You said: <span class=\"token constantCharacter\">{{$parseTree.text}}</span>.\n\n    <span class=\"token keyword\">state:</span>\n        <span class=\"token storageType\">event:</span> sessionDataSoftLimitExceeded    <span class=\"token comment\">// process the “soft limit reached” event</span>\n        <span class=\"token variableParameter\">script:</span>\n            delete session.text;               <span class=\"token comment\">// session data are deleted when the soft limit is reached</span></code></pre></div>","frontmatter":{"title":"","description":null},"headings":[{"value":"session and client object data overflow processing in the script"}]}},"pageContext":{"slug":"/docs/en/JS_API/overflow_session_client_data/","previous":{"fields":{"slug":"/docs/en/JS_API/pre_postProcess/"},"frontmatter":{"title":"","description":null}},"next":{"fields":{"slug":"/docs/en/JS_API/global_scope/"},"frontmatter":{"title":"","description":null}}}},
    "staticQueryHashes": ["1209419333"]}