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

NAME

PApp::Prefs - manage user-specific data.

SYNOPSIS

 use PApp::Prefs;
 # see also PApp::Session and PApp::Env

DESCRIPTION

This module manages user-specific preferences, which are simply values that get associated with a particular user.

Functions

lockprefs { BLOCK }

Execute the given block while the user preferences table is locked against changes from other processes. Needless to say, the block should execute as fast as possible. Returns the return value of BLOCK (which is called in scalar context).

Methods

$prefs = new PApp::Prefs [$pathref]

Creates a new PApp::Prefs object for the given application path. A reference to the path variable must be passed in, so that changes in the path can be tracked by the module.

$prefs->get($key)

Return the named user-preference variable (or undef, when the variable does not exist).

User preferences can be abused for other means, like timeout-based session authenticitation. This works, because user preferences, unlike state variables, change their values simultaneously in all sessions.

$prefs->set($key, $value)

Set the named preference variable. If $value is undef, then the variable will be deleted. You can pass in (serializable) references.

$ref = $prefs->ref($key)

Return a reference to the preferences value (i.e. a PApp::DataRef object). Updates to the referee will be seen by all processes.

$prefs->user_get($uid, $key)
$prefs->user_set($uid, $key, $value)
$prefs->user_ref($uid, $key)

These functions work like their counterparts without the user_-prefix, but allow you to specify the userid you want to query.

@uids = $prefs->find_value($key, $value)

Return all user ids for which the named key has the given value.

Useful for login-type functions where you look for all users with a specific value for the "username" key or similar.

SEE ALSO

PApp, PApp::User.

AUTHOR

 Marc Lehmann <schmorp@schmorp.de>
 http://home.schmorp.de/