github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/caches/memory.md (about)

     1  ---
     2  title: memory
     3  type: cache
     4  status: stable
     5  ---
     6  
     7  <!--
     8       THIS FILE IS AUTOGENERATED!
     9  
    10       To make changes please edit the contents of:
    11       lib/cache/memory.go
    12  -->
    13  
    14  import Tabs from '@theme/Tabs';
    15  import TabItem from '@theme/TabItem';
    16  
    17  
    18  Stores key/value pairs in a map held in memory. This cache is therefore reset
    19  every time the service restarts. Each item in the cache has a TTL set from the
    20  moment it was last edited, after which it will be removed during the next
    21  compaction.
    22  
    23  
    24  <Tabs defaultValue="common" values={[
    25    { label: 'Common', value: 'common', },
    26    { label: 'Advanced', value: 'advanced', },
    27  ]}>
    28  
    29  <TabItem value="common">
    30  
    31  ```yaml
    32  # Common config fields, showing default values
    33  label: ""
    34  memory:
    35    ttl: 300
    36    compaction_interval: 60s
    37    init_values: {}
    38  ```
    39  
    40  </TabItem>
    41  <TabItem value="advanced">
    42  
    43  ```yaml
    44  # All config fields, showing default values
    45  label: ""
    46  memory:
    47    ttl: 300
    48    compaction_interval: 60s
    49    shards: 1
    50    init_values: {}
    51  ```
    52  
    53  </TabItem>
    54  </Tabs>
    55  
    56  The compaction interval determines how often the cache is cleared of expired
    57  items, and this process is only triggered on writes to the cache. Access to the
    58  cache is blocked during this process.
    59  
    60  Item expiry can be disabled entirely by either setting the
    61  `compaction_interval` to an empty string.
    62  
    63  The field `init_values` can be used to prepopulate the memory cache
    64  with any number of key/value pairs which are exempt from TTLs:
    65  
    66  ```yaml
    67  memory:
    68    ttl: 60
    69    init_values:
    70      foo: bar
    71  ```
    72  
    73  These values can be overridden during execution, at which point the configured
    74  TTL is respected as usual.
    75  
    76  ## Fields
    77  
    78  ### `ttl`
    79  
    80  The TTL of each item in seconds. After this period an item will be eligible for removal during the next compaction.
    81  
    82  
    83  Type: `int`  
    84  Default: `300`  
    85  
    86  ### `compaction_interval`
    87  
    88  The period of time to wait before each compaction, at which point expired items are removed.
    89  
    90  
    91  Type: `string`  
    92  Default: `"60s"`  
    93  
    94  ### `shards`
    95  
    96  A number of logical shards to spread keys across, increasing the shards can have a performance benefit when processing a large number of keys.
    97  
    98  
    99  Type: `int`  
   100  Default: `1`  
   101  
   102  ### `init_values`
   103  
   104  A table of key/value pairs that should be present in the cache on initialization. This can be used to create static lookup tables.
   105  
   106  
   107  Type: `object`  
   108  Default: `{}`  
   109  
   110  ```yaml
   111  # Examples
   112  
   113  init_values:
   114    Nickelback: "1995"
   115    Spice Girls: "1994"
   116    The Human League: "1977"
   117  ```
   118  
   119