NAME

Starch::Store - Base role for Starch stores.

DESCRIPTION

This role defines an interfaces for Starch store classes. Starch store classes are meant to be thin wrappers around the store implementations (such as DBI, CHI, etc).

See "STORES" in Starch for instructions on using stores and a list of available Starch stores.

See "STORES" in Starch::Extending for instructions on writing your own stores.

This role adds support for method proxies to consuming classes as described in "METHOD PROXIES" in Starch.

REQUIRED ARGUMENTS

manager

The Starch::Manager object which is used by stores to access configuration and create sub-stores (such as the Layered store's outer and inner stores). This is automatically set when the stores are built by Starch::Factory.

OPTIONAL ARGUMENTS

max_expires

Set the per-store maximum expires which will override the state's expires if the state's expires is larger.

key_separator

Used by "stringify_key" to combine the state namespace and ID. Defaults to :.

ATTRIBUTES

can_reap_expired

Return true if the stores supports the "reap_expired" method.

short_store_class_name

Returns "short_class_name" in Starch::Role::Log with the Store:: prefix remove.

METHODS

new_sub_store

Builds a new store object. Any arguments passed will be combined with the "sub_store_args".

sub_store_args

Returns the arguments needed to create a sub-store. Any arguments passed will be combined with the default arguments. The default arguments will be "manager" and "max_expires" (if set). More arguments may be present if any plugins extend this method.

calculate_expires

Given an expires value this will calculate the expires that this store should use considering what "max_expires" is set to.

stringify_key

my $store_key = $starch->stringify_key(
    $state_id,
    \@namespace,
);

This method is used by stores that store and lookup data by a string (all of them at this time). It combines the state ID with the "namespace" in Starch::Manager of the key data for the store request.

reap_expired

This triggers the store to find and delete all expired states. This is meant to be used in an offline process, such as a cronjob, as finding and deleting the states could take hours depending on the amount of data and the storage engine's speed.

By default this method will throw an exception if the store does not define its own reap method. You can check if a store supports this method by calling "can_reap_expired".

SUPPORT

See "SUPPORT" in Starch.

AUTHORS

See "AUTHORS" in Starch.

COPYRIGHT AND LICENSE

See "COPYRIGHT AND LICENSE" in Starch.