Expiration policy

More about the expiration policy

expiration-policy:          # 1.
  type: access              # 1.1
  time:                     # 1.2
    expire-after: 1m        # 1.2.1
  size:                     # 1.3
    maximum: 1000           # 1.3.1

Httpstub provides three basic types of evictions: size-based eviction, time-based eviction, and access-based eviction.

size-based - Controls that the recorder should not store recordings larger than a certain size. The recorder storage will attempt to delete recordings that have not been used recently or very often. Warning: the storage may delete recordings before this limit is exceeded - usually when the storage size is approaching the limit.

Allowed settings:

Name
Type
Available values

maximum

java.lang.Integer

1, 500, 30000

time-based - When using this policy, record retention ceases after a specified amount of time has elapsed since the record was created. This can be useful if cached data becomes obsolete after a certain amount of time. Time expiration is performed with periodic maintenance during writes and occasionally during reads.

Allowed settings:

Name
Type
Available values
Comment

expire-after

java.time.Duration

1h, 5m, 30s, 1000ms

Parsing is done through org.springframework.boot.convertюDurationStyle#detectAndParse(String)

access-based - Evict data only after a specified time has elapsed since the last read access to the record. Note that the order of eviction of records will be similar to the order of eviction by size.

This policy has no settings

Examples

Expiration policy - time

#data/recorder-example.yaml
version: v1.2
type: OutboundRecorder
rules:
  - request:                      
      path: /api/**     
    recorder:                     
      storage:                    
        type: memory              
      expiration-policy:          
        type: time                
        time:                     
          expire-after: 1m        

Entry expires 1 minute after writing

Expiration policy - size

#data/recorder-example.yaml
version: v1.2
type: OutboundRecorder
rules:
  - request:                      
      path: /api/**     
    recorder:                     
      storage:                    
        type: memory              
      expiration-policy:          
        type: time
        size:
          maximum: 1000        

Stores one thousand records

Expiration policy - access

#data/recorder-example.yaml
version: v1.2
type: OutboundRecorder
rules:
  - request:                      
      path: /api/**     
    recorder:                     
      storage:                    
        type: memory              
      expiration-policy:          
        type: access

Entry expires after access, stored for 1 day and unlimited size

Last updated