Skip to main content

CREATE EXTERNAL CACHE

Note

In this release, this is not a cache. Striim queries the external database as data is needed. If the same data is needed again, Striim queries it again.

CREATE EXTERNAL CACHE <name> (
  AdapterName:'DatabaseReader',
  Username: '<username>',
  Password: '<password>',
  ConnectionURL: '<database connection string>',
  ConnectionRetry: <parameters>,
  FetchSize: <count>,
  Table: '<table name>',
  Columns: '<colums to read>',
  KeyToMap: '<column name>',
  SkipInvalid: <True / False>
)  
OF <type name>;

For better performance, lookups are buffered in memory and queried in batches. The size of the buffer is set automatically.

When an external cache is joined with a window, by default the buffer will hold the same number of events as the window. You may increase the size of the buffer by adding [EXCACHEBUFFERSIZE <number of events>] to the properties of the CQ that performs the join, or disable it entirely by adding [EXCACHEBUFFERSIZE 0](.

  • AdapterName must be DatabaseReader.

  • For Username, Password, ConnectionURL, FetchSize and discussion of whether you need to install a JDBC driver, see Database Reader.Database Reader

  • With the default setting, if a connection attempt is unsuccessful, the adapter will try again in 30 seconds (retryInterval. If the second attempt is unsuccessful, in 30 seconds it will try a third time (maxRetries). If that is unsuccessful, the adapter will fail and log an exception. Negative values are not supported.

  • For Table, specify a single table. See the discussion of the Tables property in Database Reader for additional information.Database Reader

  • For Columns, specify the names of the columns you wish to retrieve, separated by commas.

  • For KeyToMap specify the table's primary key column. If the table has no primary key, specify any column.

  • When skipinvalid has its default value of False, if the data in a cache does not match the defined format (for example, if it has fewer fields that are in the type), the application will terminate. To skip invalid records, set to True.

  • You may omit ConnectionRetry, FetchSize, and SkipInvalid from TQL if their default values are appropriate.

  • The OF type must match the order, number, and data types of the specified columns.

For example:

CREATE TYPE RackType(
  rack_id String KEY,
  datacenter_id String,
  rack_aisle java.lang.Integer,
  rack_row java.lang.Integer,
  slot_count java.lang.Integer
);
CREATE EXTERNAL CACHE ConfiguredRacks (
  AdapterName:'DatabaseReader',
  ConnectionURL:'jdbc:mysql://10.1.10.149/datacenter',
  Username:'username',
  Password:'passwd',
  Table:'RackList',
  Columns: "rack_id,datacenter_id,rack_aisle,rack_row,slot_count",
  KeyToMap: 'rack_id'
)
OF RackType;