NAME

Starch::Plugin::RenewExpiration - Trigger periodic writes to the store.

SYNOPSIS

    my $starch = Starch->new(
        plugins => ['::RenewExpiration'],
        renew_threshold => 10 * 60, # 10 minutes
        ...,
    );

DESCRIPTION

If your state is used for reading more than writing you may find that your states expire in the store when they are still being used since your code has not triggered a write of the state data by changing it.

This plugin causes "save" in Starch::State to save even if the state data is not dirty (normally it would just silently return). Typically you'll want to set the "renew_threshold" argument so that this write only happens after the state has gotten a little stale rather than on every time it is used.

OPTIONAL MANAGER ARGUMENTS

These arguments are added to the Starch::Manager class.

renew_threshold

How long to wait, since the last state write, before forcing save to write to the store.

Defaults to zero which will renew the expiration every time save is called.

renew_variance

In order to avoid multiple simultaneous requests from trying to renew an expiration at the same time, stampeding the store, you can set this attribute to add some randomness to the "renew_threshold" check.

This must be a ratio between 0.0 and 1.0. A renew_variance of 0.5 and a renew_threshold of 60 would cause the expiration to be renewed somewhere between 30 and 60 seconds after it was last modified.

Defaults to 0.0 which means there will be no variance.

SUPPORT

See "SUPPORT" in Starch.

AUTHORS

See "AUTHORS" in Starch.

COPYRIGHT AND LICENSE

See "COPYRIGHT AND LICENSE" in Starch.