Object Store in Detail

Jishulakshmi
3 min readMay 11, 2024

--

Object Store Connector is a Mule component that allows for simple key-value storage. Although it can serve a wide variety of use cases, it is mainly design for:

  1. Storing synchronization information, such as watermarks.

2. Storing temporal information such as access tokens.

3. Storing user information.

We have Default Object Store and Custom Object Store.

Default Object Store:

By default, each Mule app has an Object Store that is persistent and always available to the app without any configuration. Flows can use it to persist and share data.

Use a Custom Object Store

Here are some common reasons for defining custom Object Stores:

You want to partition your information by storing it in different Object Stores.

You want to use advanced Object Store features such as these:

1. Transient/Persistent storage.

2. Specification of a time to live (TTL).

3. Specification of a max capacity.

4. You want to keep different components from sharing state by feeding them with different Object Stores.

5. You want different components to share information by feeding them with the same Object Stores.

Using Custom Object store we can define two types

  1. In-memory store/Transient.
  2. File-Stored/Persistent store.

In-memory store/Transient :

Stores objects in local Mule runtime memory. Objects are lost on the shutdown of Mule runtime.( Transient: The data does not survive a Mule Runtime crash.)

File-Stored/Persistent store :

Mule persists data when an object store is explicitly configured to be persistent. In a standalone Mule runtime, Mule creates a default persistent store in the file system.( Persistent : The Object Store data survives a Mule Runtime crash.)

Object Store Connector Reference

Configurations

Field: Persistent, Type: Boolean, Default Value: true

Description: Whether the store is persistent or transient.

Field: Max entries,

Description: Not configurable for Object Store v2.

The maximum number of entries is unlimited.

Field: Entry ttl, Type: Number, Default Value: 2592000 seconds (30 days)

Description: The entry timeout.

Ignored if the value of expirationInterval is less than or equal to 0.

  • Minimum value: 1 second
  • Maximum value: 30 days

If the field contains:

  • No value
  • Mule versions 4.2.1 and later: Rolling TTL
  • Mule versions earlier than 4.2.1: Static TTL of 30 days by default
  • Less than or equal to 0
  • TTL is static and set to the maximum value (2592000 seconds/30 days).
  • Positive number
  • TTL is static and set to the specified value (between 1 and 2592000 seconds)
  • Greater than 30 days
  • TTL is static and set to the maximum value (2592000 seconds/30 days).
  • If Entry ttl is not empty, the TTL is static.
  • If you leave this field empty, you enable rolling TTL; if you exceed 2592000 seconds, the TTL defaults to 2592000 seconds.

Field: Expiration interval, Type: Positive number, Default Value: 1 minute

Description: How frequently the expiration thread should run.

Set expirationInterval to a positive value that less than the value of entryTtl.

If expirationInterval is set to a value less than or equal to zero, entryTtl is ignored.

The expirationInterval field requires that the entryTtl field is set; otherwise, it is ignored.

Operations

1. Clear : Removes all the contents in the store.

2. Contains : Checks if there is any value associated to the given key. If no value exists for the key, then false is returned.

3. Remove : Removes the value associated to the given key. If no value exists for the key, then an OS:KEY_NOT_FOUND error is thrown.

4. Retrieve : Retrieves the value stored for the given key. If no value exists for the key, behavior depends on the defaultValue parameter.

5. Retrieve All : Retrieves all the key value pairs in the object store.

6. Retrieve All Keys : Returns a List containing all keys that the object store currently holds values for.

7.Store : Stores the given value using the given key. This operation can be used either for storing new values or updating existing ones, depending on the value of the failIfPresent.

Another important consideration is regarding null values.

The default value of true makes the connector throw a NULL_VALUE error depending on the value of failOnNullValue.

OS-Store Config

--

--