Skip to content

Commit a7fd0c6

Browse files
committed
Added debug logging around cache.
1 parent 8ac619d commit a7fd0c6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Mvc/Cache/Storage/FileCacheStorage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Neuron\Mvc\Cache\Storage;
33

4+
use Neuron\Log\Log;
45
use Neuron\Mvc\Cache\Exceptions\CacheException;
56

67
class FileCacheStorage implements ICacheStorage
@@ -29,6 +30,7 @@ public function read( string $Key ): ?string
2930
{
3031
if( $this->isExpired( $Key ) )
3132
{
33+
Log::debug( "Cache entry expired for key: $Key" );
3234
$this->delete( $Key );
3335
return null;
3436
}

src/Mvc/Cache/ViewCache.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Neuron\Mvc\Cache;
33

4+
use Neuron\Log\Log;
45
use Neuron\Mvc\Cache\Exceptions\CacheException;
56
use Neuron\Mvc\Cache\Storage\ICacheStorage;
67

@@ -40,7 +41,17 @@ public function get( string $Key ): ?string
4041
return null;
4142
}
4243

43-
return $this->_Storage->read( $Key );
44+
$Data = $this->_Storage->read( $Key );
45+
46+
if( !$Data )
47+
{
48+
Log::debug( "Cache miss for key: $Key" );
49+
return null;
50+
}
51+
52+
Log::debug( "Cache hit for key: $Key" );
53+
54+
return $Data;
4455
}
4556

4657
/**
@@ -205,4 +216,4 @@ private function shouldRunGc(): bool
205216
// Roll the dice
206217
return mt_rand( 1, $Divisor ) <= ( $Probability * $Divisor );
207218
}
208-
}
219+
}

0 commit comments

Comments
 (0)