Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
5fefbbd8
Commit
5fefbbd8
authored
Jul 09, 2007
by
jepso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation cache uses 'Last Changed Rev' instead of 'Last Changed Date' now.
parent
4cb332fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
14 deletions
+28
-14
Cache.php
manual/new/Cache.php
+5
-8
index.php
manual/new/index.php
+23
-6
No files found.
manual/new/Cache.php
View file @
5fefbbd8
...
...
@@ -6,13 +6,11 @@ class Cache
protected
$_ext
;
protected
$_page
;
protected
$_file
;
protected
$_timeToLive
;
public
function
__construct
(
$dir
,
$ext
,
$timeToLive
)
public
function
__construct
(
$dir
,
$ext
)
{
$this
->
_dir
=
$dir
;
$this
->
_ext
=
$ext
;
$this
->
_timeToLive
=
$timeToLive
;
$this
->
_page
=
'http://'
.
$_SERVER
[
'HTTP_HOST'
]
.
$_SERVER
[
'REQUEST_URI'
];
$this
->
_file
=
$this
->
_dir
.
md5
(
$this
->
_page
)
.
'.'
.
$this
->
_ext
;
...
...
@@ -59,10 +57,10 @@ class Cache
*/
public
function
clear
()
{
if
(
$handle
=
opendir
(
$this
->
dir
))
{
if
(
$handle
=
opendir
(
$this
->
_
dir
))
{
while
(
$file
=
readdir
(
$handle
))
{
if
(
$file
!==
'.'
&&
$file
!==
'..'
)
{
unlink
(
$this
->
dir
.
'/'
.
$file
);
@
unlink
(
$this
->
_
dir
.
'/'
.
$file
);
}
}
closedir
(
$handle
);
...
...
@@ -72,13 +70,12 @@ class Cache
/**
* This method is used to check whether the cache file is valid to use.
*
* Currently it compares the modification date of the cache file to the
* time-to-live value.
* Currently it assumes that the cache file is always valid.
*
* @return True, if cache file is valid; false otherwise.
*/
protected
function
isValid
()
{
return
(
time
()
-
filemtime
(
$this
->
_file
))
<
$this
->
_timeToLiv
e
;
return
tru
e
;
}
}
\ No newline at end of file
manual/new/index.php
View file @
5fefbbd8
...
...
@@ -11,18 +11,35 @@ require_once('Cache.php');
spl_autoload_register
(
array
(
'Sensei'
,
'autoload'
));
// Executes the
svn info
command for the current directory and parses the last
// changed
date in order to calculate the time-to-live value for cache
.
$
timeToLive
=
0
;
// Executes the
'svn info'
command for the current directory and parses the last
// changed
revision
.
$
revision
=
0
;
exec
(
'svn info .'
,
$output
);
foreach
(
$output
as
$line
)
{
if
(
preg_match
(
'/^Last Changed
Date: (.*) \(.*\
)$/'
,
$line
,
$matches
))
{
$
timeToLive
=
time
()
-
strtotime
(
$matches
[
1
])
;
if
(
preg_match
(
'/^Last Changed
Rev: ([0-9]+
)$/'
,
$line
,
$matches
))
{
$
revision
=
$matches
[
1
]
;
break
;
}
}
$cache
=
new
Cache
(
'./cache/'
,
'cache'
,
$timeToLive
);
$cacheDir
=
'./cache/'
;
$cacheRevFile
=
$cacheDir
.
'revision.txt'
;
$cacheRev
=
0
;
$cache
=
new
Cache
(
$cacheDir
,
'cache'
);
// Checks the revision cache files were created from
if
(
file_exists
(
$cacheRevFile
))
{
$cacheRev
=
(
int
)
file_get_contents
(
$cacheRevFile
);
}
// Empties the cache directory and saves the current revision to a file, if SVN
// revision is greater than cache revision
if
(
$revision
>
$cacheRev
)
{
$cache
->
clear
();
@
file_put_contents
(
$cacheRevFile
,
$revision
);
}
if
(
$cache
->
begin
())
{
...
...
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