Some minor performance optimizations
This commit is contained in:
parent
40426c293e
commit
6fa23b98d3
1 changed files with 55 additions and 48 deletions
|
@ -260,6 +260,8 @@
|
||||||
throw new ClientNotFoundException($client_uuid);
|
throw new ClientNotFoundException($client_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::verbose(Misc::FEDERATIONLIB, sprintf('Changed client name for client %s to %s', $client_uuid, $name));
|
||||||
|
|
||||||
// Update the record in redis if caching is enabled
|
// Update the record in redis if caching is enabled
|
||||||
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
||||||
{
|
{
|
||||||
|
@ -270,8 +272,11 @@
|
||||||
Configuration::getObjectCacheServerFallback('client_objects')
|
Configuration::getObjectCacheServerFallback('client_objects')
|
||||||
);
|
);
|
||||||
|
|
||||||
if($redis->exists($client_uuid))
|
if(!$redis->exists($client_uuid))
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$redis->hSet($client_uuid, 'name', $name);
|
$redis->hSet($client_uuid, 'name', $name);
|
||||||
$redis->hSet($client_uuid, 'updated_timestamp', $update_timestamp);
|
$redis->hSet($client_uuid, 'updated_timestamp', $update_timestamp);
|
||||||
if(Configuration::getObjectCacheTTL('client_objects') > 0)
|
if(Configuration::getObjectCacheTTL('client_objects') > 0)
|
||||||
|
@ -280,15 +285,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $client_uuid, 'name'));
|
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $client_uuid, 'name'));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $client_uuid, $e->getMessage()), $e);
|
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $client_uuid, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::verbose(Misc::FEDERATIONLIB, sprintf('Changed client name for client %s to %s', $client_uuid, $name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -338,6 +341,8 @@
|
||||||
throw new ClientNotFoundException($client_uuid);
|
throw new ClientNotFoundException($client_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::verbose(Misc::FEDERATIONLIB, sprintf('Changed client description for client %s to %s', $client_uuid, $description));
|
||||||
|
|
||||||
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -347,8 +352,11 @@
|
||||||
Configuration::getObjectCacheServerFallback('client_objects')
|
Configuration::getObjectCacheServerFallback('client_objects')
|
||||||
);
|
);
|
||||||
|
|
||||||
if($redis->exists($client_uuid))
|
if(!$redis->exists($client_uuid))
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$redis->hSet($client_uuid, 'description', $description);
|
$redis->hSet($client_uuid, 'description', $description);
|
||||||
$redis->hSet($client_uuid, 'updated_timestamp', $updated_timestamp);
|
$redis->hSet($client_uuid, 'updated_timestamp', $updated_timestamp);
|
||||||
|
|
||||||
|
@ -358,16 +366,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $client_uuid, 'description'));
|
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $client_uuid, 'description'));
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $client_uuid, $e->getMessage()), $e);
|
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $client_uuid, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::verbose(Misc::FEDERATIONLIB, sprintf('Changed client description for client %s to %s', $client_uuid, $description));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,6 +421,8 @@
|
||||||
throw new ClientNotFoundException($client_uuid);
|
throw new ClientNotFoundException($client_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::verbose(Misc::FEDERATIONLIB, sprintf('Changed client permission role for client %s to %s', $client_uuid, $permission_role));
|
||||||
|
|
||||||
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -426,8 +432,11 @@
|
||||||
Configuration::getObjectCacheServerFallback('client_objects')
|
Configuration::getObjectCacheServerFallback('client_objects')
|
||||||
);
|
);
|
||||||
|
|
||||||
if($redis->exists($client_uuid))
|
if(!$redis->exists($client_uuid))
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$redis->hSet($client_uuid, 'permission_role', $permission_role);
|
$redis->hSet($client_uuid, 'permission_role', $permission_role);
|
||||||
$redis->hSet($client_uuid, 'updated_timestamp', $updated_timestamp);
|
$redis->hSet($client_uuid, 'updated_timestamp', $updated_timestamp);
|
||||||
|
|
||||||
|
@ -438,14 +447,11 @@
|
||||||
|
|
||||||
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $client_uuid, 'permission_role'));
|
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $client_uuid, 'permission_role'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $client_uuid, $e->getMessage()), $e);
|
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $client_uuid, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::verbose(Misc::FEDERATIONLIB, sprintf('Changed client permission role for client %s to %s', $client_uuid, $permission_role));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -481,6 +487,8 @@
|
||||||
throw new DatabaseException('Failed to update last seen timestamp: ' . $e->getMessage(), $e);
|
throw new DatabaseException('Failed to update last seen timestamp: ' . $e->getMessage(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::verbose(Misc::FEDERATIONLIB, sprintf('Updated last seen timestamp for client %s to %s', $uuid, $timestamp));
|
||||||
|
|
||||||
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
if(Configuration::isCacheSystemEnabled() && Configuration::getObjectCacheEnabled('client_objects'))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -490,8 +498,11 @@
|
||||||
Configuration::getObjectCacheServerFallback('client_objects')
|
Configuration::getObjectCacheServerFallback('client_objects')
|
||||||
);
|
);
|
||||||
|
|
||||||
if($redis->exists($uuid))
|
if(!$redis->exists($uuid))
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$redis->hSet($uuid, 'seen_timestamp', $timestamp);
|
$redis->hSet($uuid, 'seen_timestamp', $timestamp);
|
||||||
|
|
||||||
if(Configuration::getObjectCacheTTL('client_objects') > 0)
|
if(Configuration::getObjectCacheTTL('client_objects') > 0)
|
||||||
|
@ -501,14 +512,11 @@
|
||||||
|
|
||||||
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $uuid, 'seen_timestamp'));
|
Log::debug(Misc::FEDERATIONLIB, sprintf('Updated client object %s <%s> in cache', $uuid, 'seen_timestamp'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $uuid, $e->getMessage()), $e);
|
Log::warning(Misc::FEDERATIONLIB, sprintf('Failed to update client object %s in cache: %s', $uuid, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::verbose(Misc::FEDERATIONLIB, sprintf('Updated last seen timestamp for client %s to %s', $uuid, $timestamp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -604,7 +612,6 @@
|
||||||
throw new DatabaseException('Failed to list clients: ' . $e->getMessage(), $e);
|
throw new DatabaseException('Failed to list clients: ' . $e->getMessage(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unset($client);
|
unset($client);
|
||||||
return $clients;
|
return $clients;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue