Forum OpenACS Development: ad_set_client_property uses ns_cache?

Collapse
Posted by Andrew Piskorski on
So ad_set_client_property is implemented with ns_cache? Yes, I see that it is so (via util_memoize_seed). Is that really appropriate?

Seems to me that client properties should have their own cache, not the util_memoize cache, which is bounded on time but not on size. Does ns_cache support that style of use? (Or, perhaps keep the space bound, but make sure it's very large, and separate from whatever cache util_memoize uses?) You want non-persistent client properties to expire after a time, but while they're active you don't want AOLserver to throw them out just because they're large, right? Thoughts?

I'm not clear though, what happens if non-persistent client properties are evicted from the cache? Or if the AOLserver restarts, for that matter? What will the Tcl code and end user see?

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.