Starch::Store::DBI - Starch storage backend using DBI.
my $starch = Starch->new( store => { class => '::DBI', dbh => [ $dsn, $username, $password, { RaiseError => 1 }, ], table => 'my_states', }, );
This Starch store uses DBI to set and get state data.
Consider using Starch::Store::DBIx::Connector instead of this store as DBIx::Connector provides superior re-connection and transaction handling capabilities.
The table in your database should contain three columns. This is the SQLite syntax for creating a compatible table which you can modify to work for your particular database's syntax:
CREATE TABLE starch_states ( key TEXT NOT NULL PRIMARY KEY, data TEXT NOT NULL, expiration INTEGER NOT NULL )
This must be set to either array ref arguments for "connect" in DBI or a pre-built object (often retrieved using a method proxy).
When configuring Starch from static configuration files using a method proxy is a good way to link your existing DBI object constructor in with Starch so that starch doesn't build its own.
A Data::Serializer::Raw for serializing the state data for storage in the "data_column". Can be specified as string containing the serializer name, a hash ref of Data::Serializer::Raw arguments, or as a pre-created Data::Serializer::Raw object. Defaults to JSON.
JSON
Consider using the JSON::XS or Sereal serializers for speed.
JSON::XS
Sereal
Sereal will likely be the fastest and produce the most compact data.
The table name where states are stored in the database. Defaults to starch_states.
starch_states
The column in the "table" where the state ID is stored. Defaults to key.
key
The column in the "table" which will hold the state data. Defaults to data.
data
The column in the "table" which will hold the epoch time when the state should be expired. Defaults to expiration.
expiration
The SQL used to create state data.
The SQL used to update state data.
The SQL used to confirm whether state data already exists.
The SQL used to retrieve state data.
The SQL used to delete state data.
Set "set" in Starch::Store.
Set "get" in Starch::Store.
Set "remove" in Starch::Store.
Please submit bugs and feature requests to the Starch-Store-DBI GitHub issue tracker:
https://github.com/bluefeet/Starch-Store-DBI/issues
Aran Clary Deltac <bluefeet@gmail.com>
Thanks to ZipRecruiter for encouraging their employees to contribute back to the open source ecosystem. Without their dedication to quality software development this distribution would not exist.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Starch::Store::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Starch::Store::DBI
CPAN shell
perl -MCPAN -e shell install Starch::Store::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.