Skip to content

Commit

Permalink
* 1.23.1 2020-03-10
Browse files Browse the repository at this point in the history
    * Fixed a problem with the cache
  • Loading branch information
jorgecc committed Mar 11, 2020
1 parent a028e19 commit 3320a35
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,8 @@ $dao->getSequencePHP(true) // string(19) "1739032938181434311"
PdoOne adds a bit of ovehead over PDO, however it is simple a wrapper to pdo.

## Changelist
* 1.23.1 2020-03-10
* Fixed a problem with the cache
* 1.23 2020-03-10
* method toMeta()
* 1.22 2020-02-08
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eftec/pdoone",
"description": "Procedural PDO Data access class in a single Class",
"version": "1.23",
"version": "1.23.1",
"type": "library",
"keywords": [
"dao",
Expand Down
32 changes: 19 additions & 13 deletions lib/PdoOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Class PdoOne
* This class wrappes PDO but it could be used for another framework/library.
*
* @version 1.23 2020-03-10
* @version 1.23.1 2020-03-10
* @package eftec
* @author Jorge Castro Castillo
* @copyright (c) Jorge Castro C. MIT License https://github.com/EFTEC/PdoOne
Expand Down Expand Up @@ -2198,11 +2198,11 @@ public function distinct($sql = 'distinct') {
* @throws Exception
*/
public function toList($pdoMode = PDO::FETCH_ASSOC) {

$useCache=$this->useCache; // because builderReset cleans this value
$rows=$this->runGen(true, $pdoMode,'tolist');
if($this->uid) {
// we store the information of the cache.
$this->cacheService->setCache($this->uid,$this->cacheFamily,$rows,$this->useCache);
$this->cacheService->setCache($this->uid,$this->cacheFamily,$rows,$useCache);
}
return $rows;
}
Expand Down Expand Up @@ -2240,10 +2240,11 @@ public function toMeta() {
* @throws Exception
*/
public function toListSimple() {
$useCache=$this->useCache; // because builderReset cleans this value
$rows=$this->runGen(true, PDO::FETCH_COLUMN,'tolistsimple');
if($this->uid) {
// we store the information of the cache.
$this->cacheService->setCache($this->uid,$this->cacheFamily,$rows,$this->useCache);
$this->cacheService->setCache($this->uid,$this->cacheFamily,$rows,$useCache);
}
return $rows;
}
Expand Down Expand Up @@ -2318,7 +2319,8 @@ public function runGen($returnArray = true, $extraMode = PDO::FETCH_ASSOC,$extra
}

}
if($this->useCache!==false && $returnArray) {
$useCache=$this->useCache; // because builderReset cleans this value
if($useCache!==false && $returnArray) {
$this->uid=hash('sha256',$this->lastQuery.$extraMode.serialize($this->lastBindParam).$extraIdCache);
$result=$this->cacheService->getCache($this->uid,$this->cacheFamily);
if($result!==false) {
Expand All @@ -2332,6 +2334,7 @@ public function runGen($returnArray = true, $extraMode = PDO::FETCH_ASSOC,$extra
}

}

$this->runQuery($stmt);
$this->builderReset();

Expand All @@ -2341,7 +2344,7 @@ public function runGen($returnArray = true, $extraMode = PDO::FETCH_ASSOC,$extra
$stmt = null; // close
if($extraIdCache=='rungen' && $this->uid) {
// we store the information of the cache.
$this->cacheService->setCache($this->uid,$this->cacheFamily,$result,$this->useCache);
$this->cacheService->setCache($this->uid,$this->cacheFamily,$result,$useCache);
}
return $result;
} else {
Expand Down Expand Up @@ -2422,7 +2425,8 @@ public function toResult() {
* @throws Exception
*/
public function first() {
if($this->useCache!==false) {
$useCache=$this->useCache; // because builderReset cleans this value
if($useCache!==false) {
$sql = $this->sqlGen();
$this->uid=hash('sha256',$sql.PDO::FETCH_ASSOC.serialize($this->whereParamType)
.serialize($this->whereParamValue).'first');
Expand All @@ -2448,7 +2452,7 @@ public function first() {
}
if($this->uid) {
// we store the information of the cache.
$this->cacheService->setCache($this->uid,$this->cacheFamily,$row,$this->useCache);
$this->cacheService->setCache($this->uid,$this->cacheFamily,$row,$useCache);
}
return $row;
}
Expand All @@ -2469,7 +2473,8 @@ public function first() {
*/
public function firstScalar($colName = null) {
$rows=null;
if($this->useCache!==false) {
$useCache=$this->useCache; // because builderReset cleans this value
if($useCache!==false) {
$sql = $this->sqlGen();
$this->uid=hash('sha256',$sql.PDO::FETCH_ASSOC.serialize($this->whereParamType)
.serialize($this->whereParamValue).'firstscalar');
Expand Down Expand Up @@ -2501,7 +2506,7 @@ public function firstScalar($colName = null) {
}
if($this->uid) {
// we store the information of the cache.
$this->cacheService->setCache($this->uid,$this->cacheFamily,$row,$this->useCache);
$this->cacheService->setCache($this->uid,$this->cacheFamily,$row,$useCache);
}
return $row;
}
Expand All @@ -2518,7 +2523,8 @@ public function firstScalar($colName = null) {
* @see \eftec\PdoOne::first
*/
public function last() {
if($this->useCache!==false) {
$useCache=$this->useCache; // because builderReset cleans this value
if($useCache!==false) {
$sql = $this->sqlGen();
$this->uid=hash('sha256',$sql.PDO::FETCH_ASSOC.serialize($this->whereParamType)
.serialize($this->whereParamValue).'last');
Expand All @@ -2544,7 +2550,7 @@ public function last() {
}
if($this->uid) {
// we store the information of the cache.
$this->cacheService->setCache($this->uid,$this->cacheFamily,$row,$this->useCache);
$this->cacheService->setCache($this->uid,$this->cacheFamily,$row,$useCache);
}
return $row;
}
Expand Down Expand Up @@ -2869,7 +2875,7 @@ public function getCacheService() {
}

/**
* It sets to use cache (if the cacheservice is set)
* It sets to use cache (if the cacheservice is set) for the current pipelines.
*
* @param null|bool|int $ttl If null then the cache never expires.<br>
* If false then we don't use cache.<br>
Expand Down

0 comments on commit 3320a35

Please sign in to comment.