Thanks for all who gave me feedback.
This is summary. If you have comment, I appreciate it.

-----------rfc----------
Module name: psv (Persistent Server Variable)

Back Ground:
  Session servers can be used to share data. Shared memory module
can store persisent data. However, both of them are not suitable
for large static application configuration.
  For example, Celeron 466/linux needs 0.4-0.5 sec to unserialize
1MB serialized data. (It not so large, it's only 2000 elements
in my case)
  0.4-0.5 sec. for each request only for unserialising data is not
unacceptable for most web applications.

Feature:
  Maintain persisent variable for a server that does not require
unserialize.

Function:
   bool psv_register(string var_name, string access_key, array values);
     where var_name is variable name, values are array to regieter,
     key is access key for the variable.

   bool psv_is_registered(string var_name, string access_key);
     Return TRUE is var_name is registered with the access_key.

   bool psv_unregister(string var_name, string access_key);
     Unregister persistent variable.

   bool psv_get(string var_name, string access_key, [bool copy]);
     Get a persistent variable into global scope. If copy is TRUE,
     set copy of persistent variable so that users can modify as
     they want.
     (I'll make array read only if it's possible)

Implementtion:
  Shared memory (libmm) for multi-process server.
  Multi-thread server uses global with lock/unlock.

Usage:
<?php

if (!psv_is_registerd('MY_LOOKUP_TABLE','access_key_here')) {
   // array definition should be in separate file to avoid
   // parsing for real usage.
   $lookup_table = array (... very large array definition .... );
   psv_register('MY_LOOKUP_TABLE', 'access_key_here', $lookup_table);
}
else {
   psv_get('MY_LOOKUP_TABLE', 'access_key_here', $lookup_table);
}

echo $MY_LOOKUP_TABLE['var'];
// Should I make $MY_LOOKUP_TABLE auto global?
// Or I shouldn't

?>

-------end----------
BTW, There is CONSTANT_ARRAY type in Zend, but it seems it
does not work. Is CONSTANT_ARRAY fully implemented?
How does it supposed to work?

--
Yasuo Ohgaki








-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to