NAME

Maplat::Web::UserSettings - save and load user/module specific data

SYNOPSIS

This module provides handling module-specific data handling on a per user basis

DESCRIPTION

This module provides a simple interface to the PostgreSQL database for saving and loading module specific data on a per user basis. It can, for example, be used to save user specific filters to the database. It can handle complex data structures.

In the background, it uses Storable and Base64 to store complex data structures and text in a database text field. This avoids having to play around with blobs.

Configuration

<module>
        <modname>usersettings</modname>
        <pm>UserSettings</pm>
        <options>
               <db>maindb</db>
               <memcache>memcache</memcache>
        </options>
</module>

set()

This function adds or updates a setting (data structure) in the database.

It takes three arguments, $username is the username, $settingname is the key name of the setting, and $settingref is a reference to the data structure you want to store, e.g.:

$is_ok = $us->set($username, $settingname, $settingref);

It returns a boolean to indicate success or failure.

get()

This function reads a setting from database and returns a reference to the data structure.

It takes two arguments, $username is the username and $settingname is the key name of the setting.

$settingref = $us->get($username, $settingname);

delete()

This function deletes a setting from database and returns a boolean to indicate success or failure.

It takes two arguments, $username is the username and $settingname is the key name of the setting.

$is_ok = $us->delete($username, $settingname);

list()

This function lists all available settings for a username.

It takes one arguments, $username is the username.

@settingnames = $us->list($username);

Dependencies

This module is a basic web module and does not depend on other web modules.

SEE ALSO

Maplat::Web

AUTHOR

Rene Schickbauer, <rene.schickbauer@magnapowertrain.com>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.