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
a5a1a9fd
Commit
a5a1a9fd
authored
12 years ago
by
Bart Visscher
Browse files
Options
Downloads
Patches
Plain Diff
Forgot a file
parent
617de811
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/cache/fileglobal.php
+70
-0
70 additions, 0 deletions
lib/cache/fileglobal.php
with
70 additions
and
0 deletions
lib/cache/fileglobal.php
0 → 100644
+
70
−
0
View file @
a5a1a9fd
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class
OC_Cache_FileGlobal
{
protected
function
getCacheDir
()
{
$cache_dir
=
get_temp_dir
()
.
'/owncloud-'
.
OC_Util
::
getInstanceId
()
.
'/'
;
if
(
!
is_dir
(
$cache_dir
))
{
mkdir
(
$cache_dir
);
}
return
$cache_dir
;
}
public
function
get
(
$key
)
{
if
(
$this
->
hasKey
(
$key
))
{
$cache_dir
=
$this
->
getCacheDir
();
return
file_get_contents
(
$cache_dir
.
$key
);
}
return
null
;
}
public
function
set
(
$key
,
$value
,
$ttl
=
0
)
{
$cache_dir
=
$this
->
getCacheDir
();
if
(
$cache_dir
and
file_put_contents
(
$cache_dir
.
$key
,
$value
))
{
if
(
$ttl
===
0
)
{
$ttl
=
86400
;
// 60*60*24
}
return
touch
(
$cache_dir
.
$key
,
time
()
+
$ttl
);
}
return
false
;
}
public
function
hasKey
(
$key
)
{
$cache_dir
=
$this
->
getCacheDir
();
if
(
$cache_dir
&&
is_file
(
$cache_dir
.
$key
))
{
$mtime
=
filemtime
(
$cache_dir
.
$key
);
if
(
$mtime
<
time
())
{
unlink
(
$cache_dir
.
$key
);
return
false
;
}
return
true
;
}
return
false
;
}
public
function
remove
(
$key
)
{
$cache_dir
=
$this
->
getCacheDir
();
if
(
!
$cache_dir
){
return
false
;
}
return
unlink
(
$cache_dir
.
$key
);
}
public
function
clear
(){
$cache_dir
=
$this
->
getCacheDir
();
if
(
$cache_dir
and
is_dir
(
$cache_dir
)){
$dh
=
opendir
(
$cache_dir
);
while
(
$file
=
readdir
(
$dh
)){
if
(
$file
!=
'.'
and
$file
!=
'..'
){
unlink
(
$cache_dir
.
$file
);
}
}
}
}
}
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