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
b3ad23bb
Commit
b3ad23bb
authored
Feb 09, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache implementation continues
parent
20e23d99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
16 deletions
+44
-16
Cache.php
lib/Doctrine/Cache.php
+23
-15
Column.php
lib/Doctrine/Column.php
+17
-1
Statement.php
lib/Doctrine/Db/Statement.php
+4
-0
No files found.
lib/Doctrine/Cache.php
View file @
b3ad23bb
...
...
@@ -216,15 +216,11 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
$rand
=
(
mt_rand
()
/
mt_getrandmax
());
if
(
$rand
<=
$this
->
_options
[
'cleanPropability'
])
{
$content
=
file_get_contents
(
$this
->
_statsFile
);
$queries
=
explode
(
"
\n
"
,
$content
);
$queries
=
$this
->
readStats
();
$stats
=
array
();
foreach
(
$queries
as
$query
)
{
if
(
is_array
(
$query
))
{
$query
=
$query
[
0
];
}
if
(
isset
(
$stats
[
$query
]))
{
$stats
[
$query
]
++
;
}
else
{
...
...
@@ -238,17 +234,29 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
while
(
$i
--
)
{
$element
=
next
(
$stats
);
$query
=
key
(
$stats
);
if
(
is_array
(
$query
))
{
$hash
=
md5
(
serialize
(
$query
));
}
else
{
$hash
=
md5
(
$query
);
}
$hash
=
md5
(
$query
);
$this
->
_driver
->
delete
(
$hash
);
}
}
}
/**
* readStats
*
* @return array
*/
public
function
readStats
()
{
if
(
$this
->
_options
[
'statsFile'
]
!==
false
)
{
$content
=
file_get_contents
(
$this
->
_options
[
'statsFile'
]);
$e
=
explode
(
"
\n
"
,
$content
);
return
array_map
(
'unserialize'
,
$e
);
}
return
array
();
}
/**
* appendStats
*
...
...
@@ -266,7 +274,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
$rand
=
(
mt_rand
()
/
mt_getrandmax
());
if
(
$rand
<=
$this
->
_options
[
'addStatsPropability'
])
{
file_put_contents
(
$this
->
_options
[
'statsFile'
],
implode
(
"
\n
"
,
$this
->
_queries
));
file_put_contents
(
$this
->
_options
[
'statsFile'
],
implode
(
"
\n
"
,
array_map
(
'serialize'
,
$this
->
_queries
)
));
}
}
}
...
...
@@ -289,7 +297,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
$this
->
add
(
$query
,
$event
->
getInvoker
()
->
getName
());
$data
=
$this
->
_driver
->
fetch
(
md5
(
$query
));
$data
=
$this
->
_driver
->
fetch
(
md5
(
serialize
(
$query
)
));
$this
->
success
=
(
$data
)
?
true
:
false
;
...
...
@@ -303,7 +311,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
$this
->
success
=
true
;
$this
->
_driver
->
save
(
md5
(
$query
),
$data
);
$this
->
_driver
->
save
(
md5
(
serialize
(
$query
)
),
$data
);
}
}
$this
->
_data
=
$data
;
...
...
lib/Doctrine/Column.php
View file @
b3ad23bb
...
...
@@ -36,7 +36,7 @@ class Doctrine_Column extends Doctrine_Access implements IteratorAggregate, Coun
* @var array $definition
*/
protected
$_definition
=
array
(
'type'
,
'type'
=>
null
,
'length'
=>
0
,
);
/**
...
...
@@ -46,6 +46,22 @@ class Doctrine_Column extends Doctrine_Access implements IteratorAggregate, Coun
{
$this
->
_definition
=
$definition
;
}
/**
* @return array
*/
public
function
getDefinition
()
{
return
$this
->
_definition
;
}
/**
* contains
*
* @return boolean
*/
public
function
contains
(
$name
)
{
return
isset
(
$this
->
_definition
[
$name
]);
}
/**
* get
*
...
...
lib/Doctrine/Db/Statement.php
View file @
b3ad23bb
...
...
@@ -50,6 +50,10 @@ class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface
{
return
$this
->
adapter
;
}
public
function
getStatement
()
{
return
$this
->
stmt
;
}
public
function
getQuery
()
{
return
$this
->
stmt
->
queryString
;
...
...
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