Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
91180bfe
Commit
91180bfe
authored
10 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Add caching to AppConfig->getApps
parent
2ba5701b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/appconfig.php
+23
-0
23 additions, 0 deletions
lib/private/appconfig.php
with
23 additions
and
0 deletions
lib/private/appconfig.php
+
23
−
0
View file @
91180bfe
...
@@ -51,6 +51,11 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -51,6 +51,11 @@ class AppConfig implements \OCP\IAppConfig {
private
$appsLoaded
=
array
();
private
$appsLoaded
=
array
();
/**
* @var string[]
*/
private
$apps
=
null
;
/**
/**
* @param \OC\DB\Connection $conn
* @param \OC\DB\Connection $conn
*/
*/
...
@@ -90,12 +95,16 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -90,12 +95,16 @@ class AppConfig implements \OCP\IAppConfig {
/**
/**
* Get all apps using the config
* Get all apps using the config
*
* @return array an array of app ids
* @return array an array of app ids
*
*
* This function returns a list of all apps that have at least one
* This function returns a list of all apps that have at least one
* entry in the appconfig table.
* entry in the appconfig table.
*/
*/
public
function
getApps
()
{
public
function
getApps
()
{
if
(
is_array
(
$this
->
apps
))
{
return
$this
->
apps
;
}
$query
=
'SELECT DISTINCT `appid` FROM `*PREFIX*appconfig` ORDER BY `appid`'
;
$query
=
'SELECT DISTINCT `appid` FROM `*PREFIX*appconfig` ORDER BY `appid`'
;
$result
=
$this
->
conn
->
executeQuery
(
$query
);
$result
=
$this
->
conn
->
executeQuery
(
$query
);
...
@@ -103,11 +112,13 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -103,11 +112,13 @@ class AppConfig implements \OCP\IAppConfig {
while
(
$appid
=
$result
->
fetchColumn
())
{
while
(
$appid
=
$result
->
fetchColumn
())
{
$apps
[]
=
$appid
;
$apps
[]
=
$appid
;
}
}
$this
->
apps
=
$apps
;
return
$apps
;
return
$apps
;
}
}
/**
/**
* Get the available keys for an app
* Get the available keys for an app
*
* @param string $app the app we are looking for
* @param string $app the app we are looking for
* @return array an array of key names
* @return array an array of key names
*
*
...
@@ -123,6 +134,7 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -123,6 +134,7 @@ class AppConfig implements \OCP\IAppConfig {
/**
/**
* Gets the config value
* Gets the config value
*
* @param string $app app
* @param string $app app
* @param string $key key
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @param string $default = null, default value if the key does not exist
...
@@ -142,6 +154,7 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -142,6 +154,7 @@ class AppConfig implements \OCP\IAppConfig {
/**
/**
* check if a key is set in the appconfig
* check if a key is set in the appconfig
*
* @param string $app
* @param string $app
* @param string $key
* @param string $key
* @return bool
* @return bool
...
@@ -153,6 +166,7 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -153,6 +166,7 @@ class AppConfig implements \OCP\IAppConfig {
/**
/**
* sets a value in the appconfig
* sets a value in the appconfig
*
* @param string $app app
* @param string $app app
* @param string $key key
* @param string $key key
* @param string $value value
* @param string $value value
...
@@ -181,11 +195,15 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -181,11 +195,15 @@ class AppConfig implements \OCP\IAppConfig {
if
(
!
isset
(
$this
->
cache
[
$app
]))
{
if
(
!
isset
(
$this
->
cache
[
$app
]))
{
$this
->
cache
[
$app
]
=
array
();
$this
->
cache
[
$app
]
=
array
();
}
}
if
(
is_array
(
$this
->
apps
)
and
array_search
(
$app
,
$this
->
apps
)
===
false
)
{
$this
->
apps
[]
=
$app
;
}
$this
->
cache
[
$app
][
$key
]
=
$value
;
$this
->
cache
[
$app
][
$key
]
=
$value
;
}
}
/**
/**
* Deletes a key
* Deletes a key
*
* @param string $app app
* @param string $app app
* @param string $key key
* @param string $key key
* @return boolean|null
* @return boolean|null
...
@@ -203,6 +221,7 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -203,6 +221,7 @@ class AppConfig implements \OCP\IAppConfig {
/**
/**
* Remove app from appconfig
* Remove app from appconfig
*
* @param string $app app
* @param string $app app
* @return boolean|null
* @return boolean|null
*
*
...
@@ -214,6 +233,10 @@ class AppConfig implements \OCP\IAppConfig {
...
@@ -214,6 +233,10 @@ class AppConfig implements \OCP\IAppConfig {
);
);
$this
->
conn
->
delete
(
'*PREFIX*appconfig'
,
$where
);
$this
->
conn
->
delete
(
'*PREFIX*appconfig'
,
$where
);
unset
(
$this
->
cache
[
$app
]);
unset
(
$this
->
cache
[
$app
]);
if
(
is_array
(
$this
->
apps
)
and
$i
=
array_search
(
$app
,
$this
->
apps
)
!==
false
)
{
unset
(
$this
->
apps
[
$i
]);
}
$this
->
apps
=
null
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment