CACHE clause

Clears the cache when a row arrives in a stream, in either database subquery or remote subquery.

Syntax

CACHE { { CLEAR [ALL] ON source } | { MAXIMUM AGE age} | { MAXIMUM { MEMORY USAGE | SIZE } limit } } [, ...]
Components

source

The name of a stream or window defined in the same query module as the subquery. A row arriving on this stream or window causes the cache to be cleared as specified.

age

An Interval expression specifying age.

limit

An Integer expression specifying the maximum memory or size.

Usage

CACHE is an optional clause of the database subquery or remote subquery. You can use this clause to clear all or part of the cache whenever a row arrives in the specified stream and/or to set retention preferences for the cache.

In the absence of a CACHE clause Sybase CEP Engine maintains and clears the cache based on the settings of the "CacheMaximumAge," "CacheMaximumMemoryUsage," and "CacheMaximumSize" configuration preferences, defined in the file c8-services.xml. The CACHE clause overrides these preferences and offers an additional level of control over the contents of the cache. This clause can include any of the following subclauses, in any order:

The CLEAR ALL ON and CLEAR ON subclauses clear the cache independently of when queries are sent to the external database or remote service.

For more information about setting cache limits, see "Caching Data from an External Database, RPC Server, or Public Window" in the Sybase CEP Installation Guide .

See Also

Example

Here is an example of a CACHE clause used inside a database subquery. This clause sets the cache to hold rows for 45 seconds, clears records that match the rows arriving in StreamXxx and clears all records from the cache when a row arrives in StreamYyy.

INSERT INTO StreamEnriched
SELECT
   StreamOrig.*,
   Db.*
FROM
   StreamOrig,
   (DATABASE "OracleTestDB" SCHEMA "db-result.cps"
         [[
            SELECT * FROM T WHERE ?StreamOrig.i=T.id AND ?StreamOrig.s='abc'
         ]]
         CACHE
            MAXIMUM AGE 45 SECONDS
            CLEAR ON StreamXxx
            CLEAR ALL ON StreamYyy
   ) AS Db;