You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/docs/fastly:cache/SimpleCache/getOrSet.mdx
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ pagination_prev: null
6
6
---
7
7
# SimpleCache.getOrSet
8
8
9
-
The **`getOrSet()`** method attempts to get an entry from the cache for the supplied `key` if no entry is found (or has expired), the supplied `set` function is executed and it's result is inserted into the cache under the supplied `key` and for the supplied `ttl` (Time-To-Live) duration, provided in seconds.
9
+
The **`getOrSet()`** method attempts to get an entry from the cache for the supplied `key`. If no entry is found (or has expired), the supplied `set` function is executed and its result is inserted into the cache under the supplied `key` and for the supplied `ttl` (Time-To-Live) duration, provided in seconds.
10
10
11
11
## Syntax
12
12
@@ -20,14 +20,14 @@ getOrSet(key, set, length)
20
20
-`key`_: string_
21
21
- The key to lookup and/or store the supplied entry under within the cache.
22
22
-`set`_: Function_
23
-
-: A function to execute when the cache does not have a usable entry for the supplied `key`.
23
+
-The function to execute if and only if the cache does not have a usable entry for the supplied `key`.
24
24
The function should return a Promise which resolves with the following interface:
- The number of seconds to store the supplied entry within the cache for.
28
+
- The maximum number of seconds to store the supplied entry in the cache.
29
29
-`length`_: number___optional__
30
-
- The length of value being stored within the cache. This is only used when the `value` is a ReadableStream.
30
+
- The length of the value being stored within the cache. This is only used when the `value` is a `ReadableStream`.
31
31
32
32
### Return value
33
33
@@ -47,7 +47,7 @@ Returns a `SimpleCacheEntry`.
47
47
48
48
## Examples
49
49
50
-
In this example we attempt to retrieve an entry from the Fastly Cache, if the entry does not exist, we create the content and insert it into the Fastly Cache before finally returning.
50
+
In this example we attempt to retrieve an entry from the Fastly Cache. If the entry does not exist, we create the content and insert it into the Fastly Cache before finally returning.
0 commit comments