Memcache Custom Connector in Mule 4
Memcache is an in-memory key-value store short chunks of temporary data (String, object) from results of database calls, API calls, or page rendering.
Join the DZone community and get the full member experience.
Join For FreeAgenda
- What is Memcache and what is its main feature?
- Memcache platform configuration
- Custom Connector Mule 4 feature (Memcache)
- Demo
What Is Memcache and What Is Its Main Feature?
Memcache is an in-memory key-value store short chunks of temporary data (String, object) from results of database calls, API calls, or page rendering.
- Memcache is an in memory-based cache mechanism.
- Memcache is not a database.
- Memcache is not better than a database but it is being observed that in case of extended request, it performs well than persistent storage.
- Memcache does not have any backup support.
- It does not comply with any safety characteristics hence it is a high-performance tool.
- This stores data in-memory compressed items. In some scenarios, it adds latency in execution due to key management issues in memory.
- It supports distributed memory caching system which adds the feature to use more than one server to cache data.
What Type of Data Can Be Stored?
- The output of database queries (array and objects).
- Login tokens.
- Sessions.
- Temporary contents to render the page.
Memcache Platform Configuration
Limitations:
- Whether shared or applied, Memcache is not long-lasting storage. Keys can be deleted when the cache swells up, according to the cache's LRU policy. Changes in the cache form or datacenter support events can also clean some or all of the cache.
- The maximum size of a cached data value is 1 MB.
- A key should not be larger than 250 bytes.
- The "multi" batch step can have any amount of elements. The total size of the call and the total capacity of the data retrieved must not exceed 32 megabytes.
- A Memcache key cannot include a null byte.
- Memcache sustains key/value pairs. The pairs in memory at any moment change as items are recorded and recovered from the cache.
- Values saved in Memcache are retained as long as feasible. Values can be removed from the cache when a new value is added to the cache and the cache is following memory.
Demo: Custom Connector Mule 4 Feature (Memcache)
In this demo, we are demonstrating two operations:
Get Value: Extract information from Memcache
x
public String getKeyValue( MemcachedConnection connection)
……… (String) this.c.get(keyValue);
}
Set Value: Push data to Memcache with key
xxxxxxxxxx
public boolean putKeyValue( MemcachedConnection connection, String value, int secondsToLive) {
……..c.set(keyValue, secondsToLive, value)
}
Demo Video
Published at DZone with permission of Sadik Ali. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments