looking for light-weight data persistence solution in perl

后端 未结 6 1467
离开以前
离开以前 2021-02-14 11:29

In my app I need to store some simple data both in memroy and in disk. A real database will be overkill in my case, so I need lighter one to handle the simple data persistence r

6条回答
  •  广开言路
    2021-02-14 12:14

    Do you want your data to be transparently persisted, i.e. you won't have to worry about doing a commit()-type operation after every write? I just asked a very similar question: Simple, modern, robust, transparent persistence of data strutures for Perl, and listed all the solutions I found.

    If you do want transparent persistence (autocommit), then DBM::Deep may be easier to use than Storable. Here is example code that works out of the box:

    use DBM::Deep;
    
    tie my %db, 'DBM::Deep', 'file.db';
    
    if ( exists $db{foo}->{bar} ) {
        print $db{foo}->{bar}, "\n"
    } else {
        $db{foo}->{bar} = 'baz';
    }    
    

提交回复
热议问题