Persistant Storage
Prev | Home | Next

## Persistant Storage

At this time it is only possible to have three collections in which data is stored persistantly (i.e. data available to multiple requests). These are: `IP`, `SESSION` and `USER`.

Every collection contains several built-in variables that are available and are read-only unless otherwise specified:

1. `CREATE_TIME` - date/time of the creation of the collection.

2. `IS_NEW` - set to 1 if the collection is new (not yet persisted) otherwise set to 0.

3. `KEY` - the value of the initcol variable (the client's IP address in the example).

4. `LAST_UPDATE_TIME` - date/time of the last update to the collection.

5. `TIMEOUT` - date/time in seconds when the collection will be updated on disk from memory (if no other updates occur). This variable may be set if you wish to specifiy an explicit expiration time (default is 3600 seconds).

6. `UPDATE_COUNTER` - how many times the collection has been updated since creation.

7. `UPDATE_RATE` - is the average rate updates per minute since creation.

To create a collection to hold session variables (`SESSION`) use action `setsid`. To create a collection to hold user variables (`USER`) use action `setuid`. To create a collection to hold client address variables (`IP`) use action `initcol`.

### Note

ModSecurity implements atomic updates of persistent variables only for integer variables (counters) at this time. Variables are read from storage whenever `initcol` is encountered in the rules and persisted at the end of request processing. Counters are adjusted by applying a delta generated by re-reading the persisted data just before being persisted. This keeps counter data consistent even if the counter was modified and persisted by another thread/process during the transaction.

### Note

ModSecurity uses a Berkley Database (SDBM) for persistant storage. This type of database is generally limited to storing a maximum of 1008 bytes per key. This may be a limitation if you are attempting to store a considerable amount of data in variables for a single key. Some of this limitation is planned to be reduced in a future version of ModSecurity.

Prev |  | Next
Macro Expansion | Home | Miscellaneous Topics

Copyright (C) 2004-2010 Breach Security