Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
d750902a
Commit
d750902a
authored
Aug 29, 2018
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to user/project caching.
parent
0039e166
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
www/project_defs.php
www/project_defs.php
+9
-1
www/user_defs.php
www/user_defs.php
+10
-1
No files found.
www/project_defs.php
View file @
d750902a
...
...
@@ -84,7 +84,12 @@ class Project
# Backwards compatable lookup by pid. Will eventually flush this.
function
LookupByPid
(
$pid
)
{
$safe_pid
=
addslashes
(
$pid
);
global
$project_cache
;
# Look in cache first
if
(
array_key_exists
(
$pid
,
$project_cache
))
return
$project_cache
[
$pid
];
$query_result
=
DBQueryWarn
(
"select pid_idx from projects where pid='
$safe_pid
'"
);
...
...
@@ -96,8 +101,11 @@ class Project
$foo
=
new
Project
(
$idx
);
if
(
$foo
->
IsValid
())
if
(
$foo
->
IsValid
())
{
# Insert into cache.
$project_cache
[
$pid
]
=
$foo
;
return
$foo
;
}
return
null
;
}
...
...
www/user_defs.php
View file @
d750902a
...
...
@@ -95,15 +95,21 @@ class User
return
$foo
;
}
# Insert into cache.
$user_cache
[
"
$uid_idx
"
]
=&
$foo
;
$user_cache
[
"
$uid_idx
"
]
=&
$foo
;
$user_cache
[
$foo
->
uid
()]
=&
$foo
;
return
$foo
;
}
# Backwards compatable lookup by uid. Will eventually flush this.
function
LookupByUid
(
$uid
)
{
global
$user_cache
;
$safe_uid
=
addslashes
(
$uid
);
$status_archived
=
TBDB_USERSTATUS_ARCHIVED
;
# Look in cache first
if
(
array_key_exists
(
"
$uid
"
,
$user_cache
))
return
$user_cache
[
"
$uid
"
];
$query_result
=
DBQueryWarn
(
"select uid_idx from users "
.
"where uid='
$safe_uid
' and "
.
...
...
@@ -711,6 +717,9 @@ class User
if
(
array_key_exists
(
"
$uid_idx
"
,
$user_cache
))
unset
(
$user_cache
[
"
$uid_idx
"
]);
if
(
array_key_exists
(
$this
->
uid
(),
$user_cache
))
unset
(
$user_cache
[
$this
->
uid
()]);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment