@@ -1,12 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WebStream\Cache\Driver; |
| 3 | 3 | |
| 4 | -use WebStream\DI\Injector; |
|
| 5 | 4 | use WebStream\Module\Container; |
| 6 | 5 | use WebStream\Module\Utility\FileUtils; |
| 7 | 6 | use WebStream\Module\Utility\SecurityUtils; |
| 8 | 7 | use WebStream\IO\File; |
| 9 | -use WebStream\IO\Writer\FileWriter; |
|
| 10 | 8 | use WebStream\Exception\Extend\IOException; |
| 11 | 9 | |
| 12 | 10 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | if (!$this->isAvailableCacheLibrary()) { |
| 41 | 41 | return false; |
| 42 | 42 | } |
| 43 | - $key = $this->cacheContainer->cachePrefix . $key; |
|
| 43 | + $key = $this->cacheContainer->cachePrefix.$key; |
|
| 44 | 44 | $writer = null; |
| 45 | 45 | $isAppend = !$overwrite; |
| 46 | 46 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | ]); |
| 52 | 52 | |
| 53 | 53 | try { |
| 54 | - $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache'); |
|
| 54 | + $file = new File($this->cacheContainer->cacheDir.'/'.$key.'.cache'); |
|
| 55 | 55 | $writer = $this->cacheContainer->ioContainer->fileWriter->getWriter($file, $isAppend); |
| 56 | 56 | $writer->write($value); |
| 57 | - $this->logger->info("Execute cache save: " . $key); |
|
| 57 | + $this->logger->info("Execute cache save: ".$key); |
|
| 58 | 58 | return true; |
| 59 | 59 | } catch (IOException $e) { |
| 60 | 60 | $this->logger->warn($e->getMessage()); |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | if (!$this->isAvailableCacheLibrary()) { |
| 79 | 79 | return null; |
| 80 | 80 | } |
| 81 | - $key = $this->cacheContainer->cachePrefix . $key; |
|
| 81 | + $key = $this->cacheContainer->cachePrefix.$key; |
|
| 82 | 82 | $value = null; |
| 83 | 83 | $reader = null; |
| 84 | - $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache'); |
|
| 84 | + $file = new File($this->cacheContainer->cacheDir.'/'.$key.'.cache'); |
|
| 85 | 85 | |
| 86 | 86 | if ($file->isReadable()) { |
| 87 | 87 | try { |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | $data = $this->decode($reader->read()); |
| 91 | 91 | if ($data['ttl'] > 0) { |
| 92 | 92 | if (time() > $data['time'] + $data['ttl']) { |
| 93 | - $this->logger->info("Expired cache: " . $key); |
|
| 93 | + $this->logger->info("Expired cache: ".$key); |
|
| 94 | 94 | $file->delete(); |
| 95 | 95 | } |
| 96 | 96 | } else { |
| 97 | 97 | $value = $data['data']; |
| 98 | - $this->logger->info("Execute cache read: " . $key); |
|
| 98 | + $this->logger->info("Execute cache read: ".$key); |
|
| 99 | 99 | } |
| 100 | 100 | } catch (IOException $e) { |
| 101 | 101 | $this->logger->warn($e->getMessage()); |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | if (!$this->isAvailableCacheLibrary()) { |
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | - $key = $this->cacheContainer->cachePrefix . $key; |
|
| 124 | + $key = $this->cacheContainer->cachePrefix.$key; |
|
| 125 | 125 | $result = false; |
| 126 | 126 | |
| 127 | - $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache'); |
|
| 127 | + $file = new File($this->cacheContainer->cacheDir.'/'.$key.'.cache'); |
|
| 128 | 128 | if ($file->isWritable()) { |
| 129 | 129 | $result = $file->delete(); |
| 130 | - $this->logger->info("Execute cache cleared: " . $key); |
|
| 130 | + $this->logger->info("Execute cache cleared: ".$key); |
|
| 131 | 131 | } else { |
| 132 | - $this->logger->warn("Failed to clear cache: " . $key); |
|
| 132 | + $this->logger->warn("Failed to clear cache: ".$key); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $result; |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | $file = new File($filepath); |
| 155 | 155 | if ($file->isWritable()) { |
| 156 | 156 | if ($file->delete()) { |
| 157 | - $this->logger->info("Execute cache cleared: " . $this->cacheContainer->cachePrefix . "*"); |
|
| 157 | + $this->logger->info("Execute cache cleared: ".$this->cacheContainer->cachePrefix."*"); |
|
| 158 | 158 | } else { |
| 159 | - $this->logger->warn("Failed to clear cache: " . $this->cacheContainer->cachePrefix . "*"); |
|
| 159 | + $this->logger->warn("Failed to clear cache: ".$this->cacheContainer->cachePrefix."*"); |
|
| 160 | 160 | $result = false; |
| 161 | 161 | } |
| 162 | 162 | } else { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } else { |
| 172 | - $this->logger->warn("Can't read directory:" . $dir->getFilePath()); |
|
| 172 | + $this->logger->warn("Can't read directory:".$dir->getFilePath()); |
|
| 173 | 173 | $result = false; |
| 174 | 174 | } |
| 175 | 175 | |