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
35a760aa
Commit
35a760aa
authored
Feb 08, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
42827580
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
24 deletions
+40
-24
Cache.php
lib/Doctrine/Cache.php
+40
-24
No files found.
lib/Doctrine/Cache.php
View file @
35a760aa
...
...
@@ -38,8 +38,8 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
protected
$_options
=
array
(
'size'
=>
1000
,
'lifeTime'
=>
3600
,
'statsPropability'
=>
0.75
,
'savePropability'
=>
0.
8
0
,
'cleanPropability'
=>
0.
98
,
'savePropability'
=>
0.
1
0
,
'cleanPropability'
=>
0.
01
,
'statsFile'
=>
'../data/stats.cache'
,
);
/**
...
...
@@ -269,22 +269,33 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
public
function
onPreQuery
(
Doctrine_Db_Event
$event
)
{
$query
=
$event
->
getQuery
();
$data
=
false
;
// only process SELECT statements
if
(
substr
(
trim
(
strtoupper
(
$query
)),
0
,
6
)
==
'SELECT'
)
{
$this
->
add
(
$query
,
$event
->
getInvoker
()
->
getName
());
$data
=
$this
->
_driver
->
fetch
(
md5
(
$query
));
$this
->
success
=
(
$data
)
?
true
:
false
;
if
(
!
$data
)
{
$rand
=
(
rand
(
1
,
10000
)
/
(
10000
*
100
));
if
(
$rand
<
$this
->
_options
[
'savePropability'
])
{
$stmt
=
$event
->
getInvoker
()
->
query
(
$query
);
$data
=
$stmt
->
fetchAll
(
Doctrine
::
FETCH_ASSOC
);
$this
->
success
=
true
;
$this
->
_driver
->
save
(
md5
(
$query
),
$data
);
}
}
$this
->
_data
=
$data
;
return
true
;
}
return
false
;
return
(
bool
)
$data
;
}
/**
* onPreFetch
...
...
@@ -325,7 +336,9 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
public
function
onPreExecute
(
Doctrine_Db_Event
$event
)
{
$query
=
$event
->
getQuery
();
$data
=
false
;
// only process SELECT statements
if
(
substr
(
trim
(
strtoupper
(
$query
)),
0
,
6
)
==
'SELECT'
)
{
...
...
@@ -335,28 +348,31 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
$this
->
success
=
(
$data
)
?
true
:
false
;
if
(
!
$data
)
{
$rand
=
(
rand
(
1
,
10000
)
/
(
10000
*
100
));
if
(
$rand
<
$this
->
_options
[
'savePropability'
])
{
$stmt
=
$event
->
getInvoker
()
->
execute
(
$event
->
getParams
());
$data
=
$stmt
->
fetchAll
(
Doctrine
::
FETCH_ASSOC
);
$this
->
success
=
true
;
$this
->
_driver
->
save
(
md5
(
serialize
(
array
(
$query
,
$event
->
getParams
()))),
$data
);
}
}
$this
->
_data
=
$data
;
return
true
;
}
return
false
;
return
(
bool
)
$data
;
}
/**
* onExecute
* listens the onExecute event of Doctrine_Db_Statement
*
* adds the issued query to internal query stack
* and checks if cached element exists
*
* @return boolean
*/
/**
* destructor
* processStats
*
* @return void
*/
public
function
process
()
public
function
process
Stats
()
{
$rand
=
(
rand
(
1
,
10000
)
/
(
10000
*
100
));
...
...
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