Podius::Persistence::Media::RawData - File-based persistence sub-layer for raw data
# This example is not up to date and will not work
use Podius::Persistence::Media::RawData;
$data_root_dir = '/usr/local/project/data';
$pm = new Podius::Persistence::Media::RawData($data_root_dir);
$pm->insert(
'students',
[1, 2],
[{ name => 'Tom', age => '22' }, { name => 'Bob', age => '34' }]
);
my $first_student_name = $pm->retrieve('students', [1])->[0]->{name};
$pm->delete('students', [1]);
This package implements File Based Raw Data Persistence Media for Podius Persistence Layer.
Data is stored in files. Unlike FileBased PM, where entire data for the table row is stored in one keyed file, there is an directory for every table raw named ``<table>/<key>'' and every column is stored in separate file named ``field_name.raw''. The directories are in the raw data base directory, which is specified in the constructor.
These virtual methods of the superclass are not implemented (because it is not a primary media): request_high_key, get_all_keys, get_all_tables.
the Podius::Persistence::Media manpage, the File::Operations manpage, the Exception manpage, the Debug manpage.
submint method
or aborted by rollback method.
begin method.
All changes done during transaction to Persistence Media are commited.
begin method.
All changes done during transaction to Persistence Media are restored.
* table - name of table to insert data into. If table is ARRAY ref - the last name in the array is taken as table name and all rest are taken as supertable names and links in supertables to table instance are created.
* keys - array ref of row-keys to insert data into
* complex_rows - array of elements, each representing data of one row to save. Some of the row data will be saved in specified additional tables, instead of the main table. One complex_row is an array of the form:
[
[ [ field, value ]* ],
# [ add_table, [ [ kfield, kvalue ]* ],
# [ [ rfield, rvalue ]* ], [ [ lfield, [ lvalue* ] ]* ] ]*
]
* table - name of table to update data in
* keys - array ref of row-keys to insert data into
* complex_rows - array of elements, each representing data of one row to save. Some of the row data will be saved in specified additional tables, instead of the main table. One complex_row is an array of the form:
[
# [ [ unmodified_field* ], [ unmodified_add_table_property* ] ],
[ [ field, value ]* ],
# [ add_table, [ [ kfield, kvalue ]* ],
# [ [ rfield, rvalue ]* ], [ [ lfield, [ lvalue* ] ]* ] ]*
]
* table - name of real table to retrieve data from
* table_data - array of the form:
[
[ field* ],
# [ add_table, [ ifield, [ cfield, cvalue ]* ],
# [ rfield* ], [ lfield* ] ]*
]
* keys - array ref of row-keys to retrieve data from
* out_of_tx - optional boolean flag, work outside of the transaction
[
[ value* ],
# [ [ rvalue* ], [ [ lvalue* ]* ] ]*
]
If any table key does not exist, Exception::Podius::NoTableKeyError is thrown.
* table - name of table to delete from. If table is ARRAY ref - the last name in the array is taken as table name and all rest are taken as supertable names and links in supertables to table instance are deleted.
* table_data - array of the form:
[ # [ add_table, [ ifield, [ cfield, cvalue ]* ] ]* ]
* keys - array ref of row-keys to delete
update changes done to rows pointed by keys.
Calling this method outside a transaction should have no effect.
delete method.