Skip to content

Commit

Permalink
Merge pull request #740 from zapier/hydration_cache
Browse files Browse the repository at this point in the history
PLATSUP-1015_Hydration_5min_cache
  • Loading branch information
marinahand authored Jan 31, 2024
2 parents add8362 + 54051e4 commit fdb8cda
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4175,6 +4175,7 @@ <h2 id="dehydration">Dehydration</h2>
</blockquote><p>The method <code>z.dehydrate(func, inputData)</code> has two required arguments:</p><ul>
<li><code>func</code> - the function to call to fetch the extra data. Can be any raw <code>function</code>, defined in the file doing the dehydration or imported from another part of your app. You must also register the function in the app&apos;s <code>hydrators</code> property. Note that since v10.1.0, the maximum payload size to pass to <code>z.dehydrate</code> / <code>z.dehydrateFile</code> is 6KB.</li>
<li><code>inputData</code> - this is an object that contains things like a <code>path</code> or <code>id</code> - whatever you need to load data on the other side</li>
<li>A known limitation of hydration is a 5 minute cache if the hydration call is made with identical <code>inputData</code> within that timeframe. To workaround this cache for records triggering hydration in close succession, include a unique value in the <code>inputData</code>, for example a <code>timestamp</code> in addition to the record <code>id</code>. </li>
</ul><blockquote>
<p><strong>Why do I need to register my functions?</strong> Because of how JavaScript works with its module system, we need an explicit handle on the function that can be accessed from the App definition without trying to &quot;automagically&quot; (and sometimes incorrectly) infer code locations.</p>
</blockquote><p>Here is an example that pulls in extra data for a movie:</p>
Expand Down
1 change: 1 addition & 0 deletions packages/cli/README-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ The method `z.dehydrate(func, inputData)` has two required arguments:
* `func` - the function to call to fetch the extra data. Can be any raw `function`, defined in the file doing the dehydration or imported from another part of your app. You must also register the function in the app's `hydrators` property. Note that since v10.1.0, the maximum payload size to pass to `z.dehydrate` / `z.dehydrateFile` is 6KB.
* `inputData` - this is an object that contains things like a `path` or `id` - whatever you need to load data on the other side
* A known limitation of hydration is a 5 minute cache if the hydration call is made with identical `inputData` within that timeframe. To workaround this cache for records triggering hydration in close succession, include a unique value in the `inputData`, for example a `timestamp` in addition to the record `id`.
> **Why do I need to register my functions?** Because of how JavaScript works with its module system, we need an explicit handle on the function that can be accessed from the App definition without trying to "automagically" (and sometimes incorrectly) infer code locations.
Expand Down
1 change: 1 addition & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,7 @@ The method `z.dehydrate(func, inputData)` has two required arguments:
* `func` - the function to call to fetch the extra data. Can be any raw `function`, defined in the file doing the dehydration or imported from another part of your app. You must also register the function in the app's `hydrators` property. Note that since v10.1.0, the maximum payload size to pass to `z.dehydrate` / `z.dehydrateFile` is 6KB.
* `inputData` - this is an object that contains things like a `path` or `id` - whatever you need to load data on the other side
* A known limitation of hydration is a 5 minute cache if the hydration call is made with identical `inputData` within that timeframe. To workaround this cache for records triggering hydration in close succession, include a unique value in the `inputData`, for example a `timestamp` in addition to the record `id`.
> **Why do I need to register my functions?** Because of how JavaScript works with its module system, we need an explicit handle on the function that can be accessed from the App definition without trying to "automagically" (and sometimes incorrectly) infer code locations.
Expand Down
1 change: 1 addition & 0 deletions packages/cli/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4175,6 +4175,7 @@ <h2 id="dehydration">Dehydration</h2>
</blockquote><p>The method <code>z.dehydrate(func, inputData)</code> has two required arguments:</p><ul>
<li><code>func</code> - the function to call to fetch the extra data. Can be any raw <code>function</code>, defined in the file doing the dehydration or imported from another part of your app. You must also register the function in the app&apos;s <code>hydrators</code> property. Note that since v10.1.0, the maximum payload size to pass to <code>z.dehydrate</code> / <code>z.dehydrateFile</code> is 6KB.</li>
<li><code>inputData</code> - this is an object that contains things like a <code>path</code> or <code>id</code> - whatever you need to load data on the other side</li>
<li>A known limitation of hydration is a 5 minute cache if the hydration call is made with identical <code>inputData</code> within that timeframe. To workaround this cache for records triggering hydration in close succession, include a unique value in the <code>inputData</code>, for example a <code>timestamp</code> in addition to the record <code>id</code>. </li>
</ul><blockquote>
<p><strong>Why do I need to register my functions?</strong> Because of how JavaScript works with its module system, we need an explicit handle on the function that can be accessed from the App definition without trying to &quot;automagically&quot; (and sometimes incorrectly) infer code locations.</p>
</blockquote><p>Here is an example that pulls in extra data for a movie:</p>
Expand Down

0 comments on commit fdb8cda

Please sign in to comment.