Clears the cache when a row arrives in a stream, in either database subquery or remote subquery.
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 source subclause clears the entire cache whenever a row arrives in the specified stream or window.
The CLEAR ON source subclause clears matching records in the cache when a row arrives in the specified stream or window. A cache record matches an incoming row if the column names and values of the incoming row match the cache record's. The source must indicate a stream or window with a schema identical to the one in the statement's SCHEMA clause.
The CLEAR ALL ON and CLEAR ON subclauses clear the cache independently of when queries are sent to the external database or remote service.
The MAXIMUM AGE subclause determines whether caching takes place and specifies the time interval during which data is cached, which can be no longer than 100 years. If age is 0, then Sybase CEP Server does not cache data and all other caching information is ignored. If age is -1, Sybase CEP Server does not limit the cache based on age and you must set another caching preference (either in this clause or in the file c8-services.xml).
The MAXIMUM MEMORY USAGE limit specifies a maximum number of bytes for the cache.
The MAXIMUM SIZE limit subclause limits the size of the cache to the specified number of rows.
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 .
Database Subquery
Remote Subquery
FROM Clause: Database and Remote Subquery Syntax
SCHEMA Clause
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;