github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/outputs/cache.md (about) 1 --- 2 title: cache 3 type: output 4 status: stable 5 categories: ["Services"] 6 --- 7 8 <!-- 9 THIS FILE IS AUTOGENERATED! 10 11 To make changes please edit the contents of: 12 lib/output/cache.go 13 --> 14 15 import Tabs from '@theme/Tabs'; 16 import TabItem from '@theme/TabItem'; 17 18 19 Stores each message in a [cache](/docs/components/caches/about). 20 21 22 <Tabs defaultValue="common" values={[ 23 { label: 'Common', value: 'common', }, 24 { label: 'Advanced', value: 'advanced', }, 25 ]}> 26 27 <TabItem value="common"> 28 29 ```yaml 30 # Common config fields, showing default values 31 output: 32 label: "" 33 cache: 34 target: "" 35 key: ${!count("items")}-${!timestamp_unix_nano()} 36 max_in_flight: 1 37 ``` 38 39 </TabItem> 40 <TabItem value="advanced"> 41 42 ```yaml 43 # All config fields, showing default values 44 output: 45 label: "" 46 cache: 47 target: "" 48 key: ${!count("items")}-${!timestamp_unix_nano()} 49 ttl: "" 50 max_in_flight: 1 51 ``` 52 53 </TabItem> 54 </Tabs> 55 56 Caches are configured as [resources](/docs/components/caches/about) and can target any of the following types: 57 58 - [`aws_dynamodb`](/docs/components/caches/aws_dynamodb) 59 - [`aws_s3`](/docs/components/caches/aws_s3) 60 - [`dynamodb`](/docs/components/caches/dynamodb) 61 - [`file`](/docs/components/caches/file) 62 - [`memcached`](/docs/components/caches/memcached) 63 - [`memory`](/docs/components/caches/memory) 64 - [`multilevel`](/docs/components/caches/multilevel) 65 - [`redis`](/docs/components/caches/redis) 66 - [`ristretto`](/docs/components/caches/ristretto) 67 - [`s3`](/docs/components/caches/s3) 68 69 The `target` field must point to a configured cache like follows: 70 71 ```yaml 72 output: 73 cache: 74 target: foo 75 key: ${!json("document.id")} 76 77 cache_resources: 78 - label: foo 79 memcached: 80 addresses: 81 - localhost:11211 82 ttl: 60 83 ``` 84 85 In order to create a unique `key` value per item you should use 86 function interpolations described [here](/docs/configuration/interpolation#bloblang-queries). 87 When sending batched messages the interpolations are performed per message part. 88 89 ## Performance 90 91 This output benefits from sending multiple messages in flight in parallel for 92 improved performance. You can tune the max number of in flight messages with the 93 field `max_in_flight`. 94 95 ## Fields 96 97 ### `target` 98 99 The target cache to store messages in. 100 101 102 Type: `string` 103 Default: `""` 104 105 ### `key` 106 107 The key to store messages by, function interpolation should be used in order to derive a unique key for each message. 108 This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries). 109 110 111 Type: `string` 112 Default: `"${!count(\"items\")}-${!timestamp_unix_nano()}"` 113 114 ```yaml 115 # Examples 116 117 key: ${!count("items")}-${!timestamp_unix_nano()} 118 119 key: ${!json("doc.id")} 120 121 key: ${!meta("kafka_key")} 122 ``` 123 124 ### `ttl` 125 126 The TTL of each individual item as a duration string. After this period an item will be eligible for removal during the next compaction. Not all caches support per-key TTLs, and those that do not will fall back to their generally configured TTL setting. 127 This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries). 128 129 130 Type: `string` 131 Default: `""` 132 Requires version 3.33.0 or newer 133 134 ```yaml 135 # Examples 136 137 ttl: 60s 138 139 ttl: 5m 140 141 ttl: 36h 142 ``` 143 144 ### `max_in_flight` 145 146 The maximum number of messages to have in flight at a given time. Increase this to improve throughput. 147 148 149 Type: `int` 150 Default: `1` 151 152