Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
awit-perl-toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
awit-frameworks
awit-perl-toolkit
Commits
7e9eeee0
Commit
7e9eeee0
authored
14 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
* Allow overriding of cache file
* Allow changing owner & group of cache file
parent
bd228622
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
awitpt/cache.pm
+41
-3
41 additions, 3 deletions
awitpt/cache.pm
with
41 additions
and
3 deletions
awitpt/cache.pm
+
41
−
3
View file @
7e9eeee0
...
@@ -89,14 +89,18 @@ sub Error
...
@@ -89,14 +89,18 @@ sub Error
# Initialize cache
# Initialize cache
#
#
# @param server Server object
# @param server Server object
# @param params Parameters for the cache
# @li cache_file Filename of the cache file
# @li cache_file_user Owner of the cache file
# @li cache_file_group Group of the cache file
sub
Init
sub
Init
{
{
my
$server
=
shift
;
my
(
$server
,
$params
)
=
@_
;
my
$ch
;
my
$ch
;
#
Create Cache
#
We going to pass these options to new()
$ch
=
Cache::
FastMmap
->
new
(
my
%opt
=
(
'
page_size
'
=>
2048
,
'
page_size
'
=>
2048
,
'
num_pages
'
=>
1000
,
'
num_pages
'
=>
1000
,
'
expire_time
'
=>
300
,
'
expire_time
'
=>
300
,
...
@@ -104,6 +108,40 @@ sub Init
...
@@ -104,6 +108,40 @@ sub Init
'
unlink_on_exit
'
=>
1
,
'
unlink_on_exit
'
=>
1
,
);
);
# Check if we have the optional $params
if
(
defined
(
$params
))
{
# If we have a special cache file, use it and init it too
if
(
defined
(
$params
->
{'
cache_file
'}))
{
$opt
{'
share_file
'}
=
$params
->
{'
cache_file
'};
$opt
{'
init_file
'}
=
1
;
}
}
# Create Cache
$ch
=
Cache::
FastMmap
->
new
(
%opt
);
# Check if we have the optional $params
if
(
defined
(
$params
))
{
# If we have an explicit owner set, use it
if
(
defined
(
$params
->
{'
cache_file_user
'}))
{
# Check all is ok...
my
(
$chown_user
,
$chown_group
);
if
(
!
(
$chown_user
=
getpwnam
(
$params
->
{'
cache_file_user
'})))
{
setError
("
User '
$chown_user
' appears to be invalid: $?
");
return
(
-
1
);
}
if
(
!
(
$chown_group
=
getpwnam
(
$params
->
{'
cache_file_group
'})))
{
setError
("
Group '
$chown_group
' appears to be invalid: $?
");
return
(
-
1
);
}
# Go in and chown it
if
(
!
chown
(
$chown_user
,
$chown_group
,
$opt
{'
share_file
'}))
{
setError
("
Failed to chown cache file '
"
.
$opt
{'
share_file
'}
.
"
': $!
");
return
(
-
1
);
}
}
}
# Stats
# Stats
$ch
->
set
('
Cache/Stats/Hit
',
0
);
$ch
->
set
('
Cache/Stats/Hit
',
0
);
$ch
->
set
('
Cache/Stats/Miss
',
0
);
$ch
->
set
('
Cache/Stats/Miss
',
0
);
...
...
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