Text Cache

Overview

Projects often make use of data which requires considerable time to obtain due to costly computations, network and database lag, and API calls pricing. Text Cache provides the functionality to temporarily store Text values in Appian for very low latency access. Expiration policies can be specified for each individual cache entry, allowing for flexible cache configurations. Experienced designers may utilize this plug-in in conjunction with Appian's internalize/externalize functions to directly cache queryEntity, queryProcessAnalytics or integration results.

Key Features & Functionality

  • Lightweight in-memory cache for Text values
  • Can store up to 10.000 entries.  Once the limit is reached old entries will be overwritten following the configured expiration policy:
    • Access: expires entries based on when they were last accessed
    • Create: expires entries based on when they were they were created
  • Data is compressed to minimize memory usage without impacting retrieval performance.

Functions:

  • textcacheget(key) Retrieve an entry from cache (returns null if not in cache)
  • textcacheset(key, value, expireAfter, expirationPolicy) Set an entry in cache, if the key already exists the data will be updated. Expire after given minutes (default 5)
  • textcacheremove(key) Removes an entry from cache
  • textcachelifetime(key) Expected expiration, in milliseconds from the current time, for a given key.
  • textcachesize() Number of entries in cache.

*This plug-in is not designed to store extremely large text values, caution is advised*

Anonymous
  • Totally agree with the multi-server limitation.

    On the other hand, I've tested the process <-> expression and vice versa, seems to work fine (used a Script Task node).

  • Keep in mind, that the memory this plugin uses, is NOT shared between multiple servers or between the expression runtime and the process execution engines. Putting an item into the cache from a process and retrieving it from an expression will NOT work.

  • Hi Robert, in a multi server environment each cache will have its own values, they are not in sync.

    In case of HA (as of Appian 21.1) there is single active app server running the plugins, so only in case of a failover will the cached data be lost, as the standby app server will not have any cached values.

    At the end of the day this is just a cache layer to speed up slow operations, it shouldn't be relied upon like a persistent store (for example an in memory DB).

    Hope i helps! 

    Cheers, Ricardo

  • Will this work in multi server environments (e.g., HA)?

  • v1.1.1 Release Notes
    • Added textcachekeys: returns list of active keys.
    • Fixed missing textcacheclear.
    • Bumped Appian SDK jar to 20.2.
  • Something else we observed that may need some clarification in your description. The description states that the expiration policy is used "once the limit is reached". However, we've found that the expiration policy actually prevents items from getting expired even if the cache is not full. For example, consider:

    1. An item is cached for 8 hours
    2. After 1 hour without accessing the cache, the textcachelifetime is 7 hours
    3. If the item is then accessed in the cache after 1 hour, the result of textcachelifetime is back to 8 hours

    This may have some unintended consequences, such as if your system gets heavy usage, an item may never get removed from cache. In our case, we used it to cache access tokens that expire, and found that they were cached for too long because they were regularly accessed, resulting in authentication errors.

    After we figured this out, it makes sense and we resolved our issue by switching to the "CREATE" expirationPolicy. However, this behavior wasn't clear to us from the description, so may be useful to clarify!

    It might also be useful if there was some feature like a "maximumExpireAfter" that would allow you to utilize the "ACCESS" expiration policy, but cap it out so that it eventually expires.

      thank you for the extremely useful plug-in!

  • Hi derekl, thanks for pointing this out. I have submitted a new version fixing the issue, might take a few days to be published in the marketplace.

    Regards

  • Did you hide the textcacheclear function or remove it? I am no longer able to execute textcacheclear(), I get the message:

    Expression evaluation error at function 'textcacheclear' [line 21]: The function 'textcacheclear' is unavailable.

    That function was very useful for debugging and development purposes.

  • Changelog Version 1.1.0:

    · Added textcachelifetime and textcachesize functions.

    · Time unit can now be specified in textcacheset (seconds, minutes, hours, days).

    · Increased cache max size from 10K to 100K.

    · Hidden textcacheclear function to avoid clearing the entire cache by mistake.

    · Bumped Appian compatibility to 19.4.