Cache rules and Pre-cache rules

This article describes the procedures for setting cache and pre-cache rules. 

Cache rules are defined per cluster. These are simple patterns or expressions for ScaleArc to parse against and, if matched, serve directly from ScaleArc’s memory. ScaleArc creates a hash map similar to that of memcached, which can achieve up to 12x faster performance than conventional database servers. 


Before configuring a cache pattern for a particular database user, make sure you have configured the database for the user in Users & DBs.

ScaleArc provides simple and flexible ways to create cache rules.  Note that cache patterns are case-sensitive.

  1. On the ScaleArc dashboard, click Clusters > Settings > Transparent Cache.

  2. Click on the Cache Rules tab.


  3. Configure the fields as follows:

    Field Description Default/User Input
    Query caching ON/OFF button

    Query Caching can be explicitly turned OFF or kept ON. 

    Default is ON.
    Cache limits

    Determines the maximum cache limit. 0 is the default which means unlimited up to the license limit. 

    Default is 0.
    Import Rules

    This feature enables importing the cache rules from a .csv file that was generated from ScaleArc. This option saves you the effort of recreating cache rules; for instance, you can import them from another ScaleArc cluster for reuse. 

    Enter name.
    Export File

    This feature enables exporting all the cache rules into a .csv file so that it can be imported to another ScaleArc or cluster easily. 

    Database A list of databases in the cluster. Click on the Gear icon to edit.
    Pattern stats A list of active and inactive patterns in the cluster. Click on the Gear icon to edit.
    Gear icon (edit)

    ScaleArc provides simple and flexible ways to manually create cache rules. 

    Tip: You can also create cache patterns with a one-click option through analytics from real patterns of traffic that have passed through ScaleArc. The API can create cache rules as well and pass it directly through code with a prefix to the SQL statement.

    Click the gear icon to open the Query Pattern edit screen.
    Order Determines the order in which the rules get executed. Switch the order as needed.

Query pattern 

The Query screen lets you view and define query patterns with regular expressions that filter the traffic that passes through the ScaleArc interface. You can read more about how Regular Expression patterns work here.

Any query matching a specified pattern is cached within the ScaleArc appliance for the specified TTL (time-to-live). Such cached queries are delivered to the application directly by the ScaleArc appliance significantly faster than the database thereby improving the overall performance of your application. Cache patterns added for a particular logical database apply to SQL sessions from any user who issues queries for that logical database. 

  1. On the ScaleArc dashboard, click CLUSTERS > Settings > Transparent Cache > Cache Rules tab. 

  2.  Click on the Gear icon against the database of choice. 


  3. Configure the screen as follows:

    Field Description Default/User input
    Add Pattern button Opens the related screen. Create a pattern and ensure that it fits the order in which you want it executed. You cannot edit the pattern in the same field. See below.
    Order Determines the order in which the rules get executed. Switch the order as needed.

    Patterns can include any Perl Compatible Regular Expression. We typically see wild card expression to create simple rules. This option can only be deleted.

    Delete the pattern.

    Defines when the cache expires. 

    Enter a value when you create a pattern.

    Disables or enables a cache rule from executing, depending on its state. You can enable or disable this option during or after you create the pattern.

    The default is enabled. 

    Delete icon

    You can also click on the delete icon to delete the cache rule. 

    Click the icon to delete


Add a pattern

ScaleArc provides an easy way to add a pattern to a cache rule.

  1. Click on the Add Pattern button.
  2. Enter the order number.
  3. Tab over and enter the pattern's Regular Expression in the next field.

  4. Enter the TTL value and enable/disable as required.
  5. Click Save. 
  6. To edit, delete the pattern and recreate, using the Add Pattern button. 

Pre-cache rules

In pre-cache you can specify the actual query which ScaleArc will run at a specified interval and cache the response for the same. You should have a matching pattern in Query Cache to get the response from the cache. 

Follow the steps below to add a pre-cache rule:

  1. On the ScaleArc dashboard, under the Settings column > Transparent Cache.


  2. Click the Pre-Cache Rules tab and turn on Pre-caching using the toggle button. Click Yes to change the Pre-Caching configuration.
  3. Complete the configuration as shown in the section Add a Pattern.



Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request