Data Expiration
NCache supports time-based data invalidation where you can specify the time or interval to expire your cache data. NCache maintains an index for items with time based expiration. A dedicated thread checks cache data for these expired items periodically after a configurable interval of time called Clean Interval. Clean interval is the periodic interval after which the expired items are removed from the cache. By default, expiration Clean-Up interval is 15 seconds.
You can manually edit config.ncconf and client.ncconf located at %NCHOME%/config. %NCHOME% is NCache install directory. These files can be edited through any text editor of your choice.
Important
In case you want to update any cache settings please refer to the Update Cache Config section to follow the set of steps.
Specify cleanup interval and expiration policy through config.ncconf file located at %NCHOME%\config. %NCHOME%
is NCache install directory. In config.ncconf of EACH server specify the <cleanup>
tag in the <cache-settings>
tag.
The following example sets default absolute expiration to true, and its value to 30 seconds.
<cache-config>
<cache-settings ... >
<expiration-policy enabled="True">
<absolute-expiration longer-enabled="False" longer-value="0"
default-enabled="True" default-value="30"/>
<sliding-expiration longer-enabled="False" longer-value="0"
default-enabled="False" default-value="30"/>
</expiration-policy>
<cleanup interval="15sec"/>
</cache-settings>
</cache-config>
NCache provides a set of default expirations that can aid you in setting your data invalidation strategies with more flexibility. All of the default expirations have a minimum value of 5 seconds.
- Default
- Default Longer
The default value if enabled will have the default value of 5 seconds if not provided in the default-value
tag or the value provided is less than 5. The user can also provide a default-longer value which is 10 seconds by default and configurable by the user. If default-longer enabled the user will set that true and provide the value for that in the <longer-value>
tag.
There are multiple scenarios where configuration of expiration policy through config.ncconf and API will overlap, which will trigger the following behaviors:
If Expiration is enabled, but default expiration is not passed from the API, Absolute Default will be used.
If a certain default Expiration mode is enabled, the same default must be passed through the API as well.
For example, when an API call receives Sliding Longer expiration:
If Default Sliding Longer is configured, it will be used as default.
If Default Sliding Longer is not configured, no expiration will take place.
If Expiration is enabled and the time value is passed through the API call, the value passed through API will be used. If no value is passed, the value configured through config.ncconf is used.
If Expiration is enabled and both policies (Sliding and Absolute) are passed through the API, an exception will be thrown.
If Expiration is disabled, an API call with any of the defaults will be ignored and items will be inserted without expiration. However, if you pass the expiration with time value from API (non-default expiration), then it will take place regardless of the configuration.
There is no validation on comparisons of values between different levels of defaults. They could be equal, smaller are greater irrespective of their default level.
enabled: Enables the expiration policy.
longer-enabled: Specifies whether Longer expiration is enabled. If true, the value should be provided.
longer-value: If longer-enabled is true, the value should be provided under this tag. If no value is provided here and default-longer is enabled, the default value of 10 seconds will be used.
default-enabled: Specifies whether Default expiration is enabled. If true, the value should be provided as well.
default-value: If default-enabled is true, this value will be used for expiration. If Expiration is enabled, but default expiration is not passed from the API, Default value will be used. If no value is provided the default value of 5 seconds will be used.
cleanup-interval
is the periodic interval after which the expired items are removed from the cache. By default, its value is 15 seconds.
For more detail about the expiration strategies, see the Data Expiration section.
Note
Repeat this step for all server nodes.
See Also
Configure Caches
Configure Clients
MapReduce
General Cache Settings