Monday, August 25, 2025

Refresh Maximo Caches without Restart using Automation Script

A cache is a temporary storage layer in software systems that keeps frequently used data in memory, so it can be retrieved faster when needed again, without re-fetching it from the original slower source (e.g., a database or file system). This avoids repeated database calls, disk I/O, and expensive computations.

In MAS and Maximo 7.6.x version, caching is used to enhance performance and reduce system load. Maximo manages the caches using custom, Java-based, local in-memory caches within a JVM.

Each cache is local to the JVM within a WAS Liberty instance. It's non-persistent; the cache data will be cleared on server restart.

There are many types of caches used to improve performance. These caches store data such as metadata, application definitions, maxvars, system properties, security group, Object Structure Authorization and domain values to avoid repeated database queries. 

There are 75+ Caches available in MAS 9.0.x version, some of the known ones are listed in the below image. 

* complete list of cache is listed in this file CacheList.csv

A common requirement in production systems is to refresh cache without restarting servers to avoid outages and downtime. Fortunately, Maximo provides a method to reload caches programmatically, and we can do it with an automation script.

How to refresh Maximo Cache using Automation Script?
  • Create an Automation Script without launch point that accepts a parameter "cachename". 
  • It refreshes a specific cache or all caches in all servers 




from psdi.util import MXException
from psdi.server import MXServer

cache  = request.getQueryParam("cachename");
notvalid= True;

# Refresh a specific Maximo cache in all servers
if (cache != 'all' and cache is not None):
    notvalid = False;
    try:
        ALL_SERVERS = True
        MXServer.getMXServer().reloadMaximoCache(cache, ALL_SERVERS)
        
        bodyMessage = "\"" + cache + " Refreshed in all Servers\""
        responseBody =  '{' + "\"response\"" + ": "  + bodyMessage + '}';

    except MXException, err: 
        print "---| CACHEREFRESH ::: refreshcache  : "+str(err);
        responseBody =  '{"response": "error", "error": "'+str(err)+'"}';

#  Refresh All Maximo Caches in all servers
if (cache=='all' and cache is not None):
    notvalid = False;
    try:
        ALL_SERVERS = True
        server = MXServer.getMXServer()
        cacheNames = server.getMaximoCacheNames()
        
        for cacheName in cacheNames:
            server.reloadMaximoCache(cacheName,ALL_SERVERS)
        
        responseBody =  '{"response": "All Maximo Caches Refreshed"}';

    except MXException, err: 
        print "---| CACHEREFRESH ::: refreshcache  : "+str(err);
        responseBody =  '{"response": "error", "error": "'+str(err)+'"}';

# input param is not valid
if (notvalid):
   responseBody =  '{"response": "noactionpresent"}';
 
Code - cacherefresh.py

How to use this Script?
  • Invoke the automation script via https REST API GET call with query parameter "cachename"

If cachename = all, it will refresh all caches in all servers.

https://hostname/maximo/oslc/script/CACHEREFRESH?lean=1&cachename=all
Output: {"response": "All Maximo Caches Refreshed"}



If cachename=<AnyValidCacheName>, it will refresh a specific cache in all servers.

https://hostname/maximo/oslc/script/CACHEREFRESH?lean=1&cachename=MAXPROP
Output: {"response": "MAXPROP Maximo Cache Refreshed"}


If cachename is null, it will throw an error message.

https://hostname/maximo/oslc/script/CACHEREFRESH?lean=1
Output: {"response": "noactionpresent"}


On a few cases, such as the Integration Cache (MAXEXTIFACEOUT), refreshing during normal business hours is not recommended. Doing so can disrupt live transactions coming from middleware, as they may not receive the latest cache data. It’s best to schedule these cache refresh operations during off-peak or after-hours periods when transaction volumes are minimal.

References: