The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

BusyBird::StatusStorage::SQLite - status storage in SQLite database

SYNOPSIS

    use BusyBird;
    use BusyBird::StatusStorage::SQLite;
    
    my $storage = BusyBird::StatusStorage::SQLite->new(
        path => 'path/to/storage.sqlite3',
        max_status_num => 5000
    );
    
    busybird->set_config(
        default_status_storage => $storage
    );

DESCRIPTION

This is an implementation of BusyBird::StatusStorage interface. It stores statuses in an SQLite database.

This storage is synchronous, i.e., all operations block the thread and the callback is called before the method returns.

CLASS METHOD

$storage = BusyBird::StatusStorage::SQLite->new(%args)

The constructor.

Fields in %args are:

path => FILE_PATH (mandatory)

Path string to the SQLite database file. If ':memory:' is specified, it creates a temporary in-memory storage.

max_status_num => INT (optional, default: 2000)

The maximum number of statuses the storage guarantees to store per timeline. You cannot expect a timeline to keep more statuses than this number.

hard_max_status_num => INT (optional, default: 120% of max_status_num)

The hard limit max number of statuses the storage is able to store per timeline. When the number of statuses in a timeline exceeds this number, it deletes old statuses from the timeline so that the timeline has max_status_num statuses.

vacuum_on_delete => INT (optional, default: 200% of max_status_num)

The status storage automatically executes VACUUM every time this number of statuses are deleted from the storage. The number is for the whole storage, not per timeline.

If you set this option less than or equal to 0, it never VACUUM itself.

OBJECT METHODS

BusyBird::StatusStorage::SQLite implements all object methods in BusyBird::StatusStorage. In addition to it, it has the following methods.

$storage->vacuum()

Executes SQL VACUUM on the database.

@timeline_names = $storage->get_timeline_names()

Returns all timeline names in the $storage.

AUTHOR

Toshio Ito <toshioito [at] cpan.org>