Forum OpenACS Development: Re: ad_set_client_property uses ns_cache?

Collapse
Posted by Tom Jackson on
Well, util_memoize isn't storage. If you can't guarantee a particular lifetime for the data, it isn't really a programming model. I can't think of a single reason to use util_memoize for storing a single user's data. Data like this is essentially private and shouldn't be stored in a global structure. The closest concept is a session variable, which should be stored somewhere for a guaranteed length of time, or until the session is expired by client or server. But if the data is personally valuable, maybe it should be stored so that the user can decide to either commit it to the larger database, delete it, or just let it stay around for a later decision. Caching should probably not be part of this process, as caching implies that there is a master copy somewhere.
Collapse
Posted by Jorge Couchet on
Hi,

In order to guarantee the permanence of the data I'm using the database. I have created the following table:

------ *******************************************
------ *******************************************
------ start SESSION_VARIABLES
------ *******************************************
------ *******************************************

-- start table SESSION_VARIABLES

CREATE TABLE session_variables (
session_id integer,
module_id varchar,
var_name varchar,
var_value varchar CONSTRAINT session_variables_var_value_nn
NOT NULL,
CONSTRAINT session_variables_pk
PRIMARY KEY(session_id, module_id, var_name)
);

COMMENT ON TABLE session_variables IS '
The table holds session variables. The programmer is in charge to delete the variables rows, if not the data is holded permanently.
';

COMMENT ON COLUMN session_variables.session_id IS '
The session ID of the user (obtained with the command [ad_conn session_id]).
';

COMMENT ON COLUMN session_variables.module_id IS '
The package key plus the package id ( "package_key_[ad_conn package_id]").
';

-- end table SESSION_VARIABLES

------ *******************************************
------ *******************************************
------ end SESSION_VARIABLES
------ *******************************************
------ *******************************************

I don't know if there is a better model, but this one is working fine to me.

Regards,

Jorge.