[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16807] API: use database for some of the user cachin
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16807] API: use database for some of the user caching to make it persistant |
Date: |
Wed, 31 May 2017 11:48:15 -0400 (EDT) |
Revision: 16807
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16807
Author: sigurdne
Date: 2017-05-31 11:48:15 -0400 (Wed, 31 May 2017)
Log Message:
-----------
API: use database for some of the user caching to make it persistant
Modified Paths:
--------------
trunk/phpgwapi/inc/class.cache.inc.php
trunk/phpgwapi/setup/setup.inc.php
trunk/phpgwapi/setup/tables_update.inc.php
Modified: trunk/phpgwapi/inc/class.cache.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.cache.inc.php 2017-05-31 13:18:05 UTC (rev
16806)
+++ trunk/phpgwapi/inc/class.cache.inc.php 2017-05-31 15:48:15 UTC (rev
16807)
@@ -38,6 +38,22 @@
class phpgwapi_cache
{
/**
+ * Decide whether to use database for caching - or not
+ *
+ * @param string $module the module name the data belongs to
+ * @param string $id the internal module id for the data
+ * @return bool use database
+ */
+ protected static function _use_database($module, $id)
+ {
+ $use_database = array(
+ 'controller' => array('location_bookmark' =>
true),
+ 'phpgwapi' => array('bookmark_menu' => true)
+ );
+ return !!$use_database[$module][$id];
+ }
+
+ /**
* Clear stored data from shared memory
*
* @param string $key the data identifier
@@ -312,7 +328,7 @@
*/
public static function user_clear($module, $id, $uid)
{
- $db = false;
+ $db = self::_use_database($module, $id);
if($db)
{
return self::_user_clear_db($module, $id, $uid);
@@ -333,7 +349,7 @@
*/
public static function user_get($module, $id, $uid, $bypass =
true, $compress = false)
{
- $db = false;
+ $db = self::_use_database($module, $id);
if($db)
{
return self::_user_get_db($module, $id, $uid,
$bypass, $compress);
@@ -355,7 +371,7 @@
*/
public static function user_set($module, $id, $value, $uid,
$bypass = true, $compress = false)
{
- $db = false;
+ $db = self::_use_database($module, $id);
if($db)
{
return self::_user_set_db($module, $id, $value,
$uid, $bypass, $compress);
@@ -498,7 +514,7 @@
* @param int $uid the user id to the data is stored for
* @return mixed the data from user cache
*/
- protected static function _user_get($module, $id, $uid, $bypass
= true, $compress = false)
+ static function _user_get($module, $id, $uid, $bypass = true,
$compress = false)
{
$uid = (int) $uid;
$module = $module . '_' . $uid;
Modified: trunk/phpgwapi/setup/setup.inc.php
===================================================================
--- trunk/phpgwapi/setup/setup.inc.php 2017-05-31 13:18:05 UTC (rev 16806)
+++ trunk/phpgwapi/setup/setup.inc.php 2017-05-31 15:48:15 UTC (rev 16807)
@@ -12,7 +12,7 @@
// Basic information about this app
$setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'phpgwapi';
- $setup_info['phpgwapi']['version'] = '0.9.17.555';
+ $setup_info['phpgwapi']['version'] = '0.9.17.556';
$setup_info['phpgwapi']['versions']['current_header'] = '1.31';
$setup_info['phpgwapi']['versions']['system'] = '2.0';
$setup_info['phpgwapi']['enable'] = 3;
Modified: trunk/phpgwapi/setup/tables_update.inc.php
===================================================================
--- trunk/phpgwapi/setup/tables_update.inc.php 2017-05-31 13:18:05 UTC (rev
16806)
+++ trunk/phpgwapi/setup/tables_update.inc.php 2017-05-31 15:48:15 UTC (rev
16807)
@@ -3520,3 +3520,55 @@
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
}
+
+
+ /**
+ * Use database for user cache
+ * @return string the new version number
+ */
+
+ $test[] = '0.9.17.555';
+ function phpgwapi_upgrade0_9_17_555()
+ {
+ phpgw::import_class('phpgwapi.cache');
+ $GLOBALS['phpgw']->db = & $GLOBALS['phpgw_setup']->oProc->m_odb;
+
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT config_value FROM
phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'temp_dir'");
+ $GLOBALS['phpgw_setup']->oProc->next_record();
+ $GLOBALS['phpgw_info']['server']['temp_dir'] =
$GLOBALS['phpgw_setup']->oProc->f('config_value');
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT config_value FROM
phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'install_id'");
+ $GLOBALS['phpgw_setup']->oProc->next_record();
+ $GLOBALS['phpgw_info']['server']['install_id'] =
$GLOBALS['phpgw_setup']->oProc->f('config_value');
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT account_id FROM
phpgw_accounts WHERE account_id = 7 AND account_type = 'u' AND account_status =
'A'");
+
+ $users = array();
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $users[] =
$GLOBALS['phpgw_setup']->oProc->f('account_id');
+ }
+
+ foreach ($users as $user_id)
+ {
+ //from file
+ if($bookmarks = phpgwapi_cache::_user_get('controller',
"location_bookmark", $user_id))
+ {
+ //to database
+ phpgwapi_cache::user_set('controller',
"location_bookmark", $bookmarks, $user_id);
+ }
+
+ //from file
+ if($bookmarks = phpgwapi_cache::_user_get('phpgwapi',
"bookmark_menu", $user_id))
+ {
+ //to database
+ phpgwapi_cache::user_set('phpgwapi',
"bookmark_menu", $bookmarks, $user_id);
+ }
+ }
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['phpgwapi']['currentver'] =
'0.9.17.556';
+ return $GLOBALS['setup_info']['phpgwapi']['currentver'];
+ }
+ }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16807] API: use database for some of the user caching to make it persistant,
sigurdne <=