NAME
Flux::File - file storage
VERSION
version 1.01
SYNOPSIS
$storage = Flux::File->new($filename);
$in = $storage->in(
Flux::File::Cursor->new($posfile)
);
DESCRIPTION
This is a simplest implementation of Flux::Storage
.
It stores lines by appending them to the file. It supports clients identifiable by Flux::File::Cursor objects.
It also have several options for fine control over performance vs data consistency trade-off. (See the constructor documentation below.)
METHODS
- new($file, [$options])
-
Create new object.
$file
should be a name of any writable file into which lines will be appended.If
$file
does not yet exist, it will be created.Options can contains the following keys:
- lock (default = 1)
-
Get lock on each write (useful when many processes writes in one file).
- reopen (default = 0)
-
Reopen file on each write (useful for files, which can be rotated).
- safe (default = 0)
-
Truncate file to the last endline (useful when your unit for writings is a single lines and you don't want to have a hanging lines in your log in case of failure). If
reopen
is true, then file checks on each flush, otherwise it will be checked only at first flush.
- write($line)
-
Write a new line into the file.
- write_chunk($chunk)
-
Write multiple lines into the file.
- in($posfile)
-
Construct the input stream which reads the file starting from the position saved in
$posfile
.
AUTHOR
Vyacheslav Matyukhin <me@berekuk.ru>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Yandex LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.