Skip to content

Commit 24fe2fc

Browse files
authored
Merge pull request #5 from byjg/issue-4
Fix PSR-4 name issue #4
2 parents f6ba962 + eb82eb3 commit 24fe2fc

File tree

9 files changed

+47
-97
lines changed

9 files changed

+47
-97
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ addons:
1010
- redis-container
1111

1212
php:
13+
- "7.4"
1314
- "7.3"
1415
- "7.2"
1516
- "7.1"
@@ -24,3 +25,11 @@ install:
2425

2526
script:
2627
- vendor/bin/phpunit --stderr
28+
29+
jobs:
30+
include:
31+
- stage: documentation
32+
if: branch = master
33+
before_install: skip
34+
install: skip
35+
script: "curl https://opensource.byjg.com/add-doc.sh | bash /dev/stdin php cache-engine-php"

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Cache Engine
22

3-
[![Opensource ByJG](https://img.shields.io/badge/opensource-byjg.com-brightgreen.svg)](http://opensource.byjg.com)
3+
[![Opensource ByJG](https://img.shields.io/badge/opensource-byjg-success.svg)](http://opensource.byjg.com)
4+
[![GitHub source](https://img.shields.io/badge/Github-source-informational?logo=github)](https://github.com/byjg/cache-engine-php/)
5+
[![GitHub license](https://img.shields.io/github/license/byjg/cache-engine-php.svg)](https://opensource.byjg.com/opensource/licensing.html)
6+
[![GitHub release](https://img.shields.io/github/release/byjg/cache-engine-php.svg)](https://github.com/byjg/cache-engine-php/releases/)
47
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/byjg/cache-engine-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/byjg/cache-engine-php/?branch=master)
58
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/f643fd22-8ab1-4f41-9bef-f9f9e127ec0d/mini.png)](https://insight.sensiolabs.com/projects/f643fd22-8ab1-4f41-9bef-f9f9e127ec0d)
6-
[![Build Status](https://travis-ci.org/byjg/cache-engine-php.svg?branch=master)](https://travis-ci.org/byjg/cache-engine-php)
9+
[![Build Status](https://travis-ci.com/byjg/cache-engine-php.svg?branch=master)](https://travis-ci.com/byjg/cache-engine-php)
710

811

912

1013
A multi-purpose cache engine PSR-6 and PSR-16 implementation with several drivers.
1114

12-
# Cache Engine PSR-16 compliant
15+
## PSR-16
1316

1417
PSR-16 defines a Simple Cache interface with less verbosity than PSR-6. Below a list
1518
of engines available in this library that is PSR-16 compliant:
@@ -44,7 +47,7 @@ $object = $cache->get('key');
4447

4548
See more PSR-16 examples [here](docs/basic-usage-psr16-simplecache.md)
4649

47-
# Cache Engine PSR-6 compliant
50+
## PSR-6
4851

4952
The PSR-6 implementation use the engines defined above. PSR-6 is more verbosity and
5053
have an extra layer do get and set the cache values.
@@ -64,7 +67,7 @@ $cachePool = new CachePool(new FileSystemCacheEngine());
6467

6568
See more PSR-6 examples [here](docs/basic-usage-psr6-cachepool.md)
6669

67-
# List of Available Factory Commands
70+
## List of Available Factory Commands
6871

6972
**Note: All parameters are optional**
7073

@@ -88,7 +91,7 @@ The Common parameters are:
8891
- servers: An array of memcached servers. E.g.: `[ '127.0.0.1:11211' ]`
8992
- config: Specific setup for shmop. E.g.: `[ 'max-size' => 524288, 'default-permission' => '0700' ]`
9093

91-
# Logging cache commands
94+
## Logging cache commands
9295

9396
You can add a PSR Log compatible to the constructor in order to get Log of the operations
9497

@@ -103,7 +106,7 @@ composer require "byjg/cache-engine=4.0.*"
103106
```
104107

105108

106-
# Running Unit Testes
109+
## Running Unit Testes
107110

108111
```
109112
phpunit --stderr

_config.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<?php
2-
/**
3-
* User: jg
4-
* Date: 27/05/17
5-
* Time: 12:21
6-
*/
72

8-
namespace ByJG\Cache;
3+
namespace ByJG\Cache\Exception;
94

10-
11-
class InvalidArgumentException extends \Exception implements \Psr\Cache\InvalidArgumentException
5+
class InvalidArgumentException extends \Exception implements \Psr\Cache\InvalidArgumentException, \Psr\SimpleCache\InvalidArgumentException
126
{
137

148
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
4+
namespace ByJG\Cache\Exception;
5+
6+
class StorageErrorException extends \Exception
7+
{
8+
9+
}

src/Psr16/BaseCacheEngine.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ByJG\Cache\Psr16;
44

55
use ByJG\Cache\CacheAvailabilityInterface;
6-
use ByJG\Cache\InvalidArgumentException;
6+
use ByJG\Cache\Exception\InvalidArgumentException;
77
use Psr\SimpleCache\CacheInterface;
88

99
abstract class BaseCacheEngine implements CacheInterface, CacheAvailabilityInterface
@@ -12,7 +12,6 @@ abstract class BaseCacheEngine implements CacheInterface, CacheAvailabilityInter
1212
* @param $keys
1313
* @param null $default
1414
* @return array|iterable
15-
* @throws \ByJG\Cache\InvalidArgumentException
1615
* @throws \Psr\SimpleCache\InvalidArgumentException
1716
*/
1817
public function getMultiple($keys, $default = null)
@@ -68,4 +67,4 @@ protected function addToNow($ttl)
6867

6968
return null;
7069
}
71-
}
70+
}

src/Psr16/MemcachedEngine.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ByJG\Cache\Psr16;
44

5+
use ByJG\Cache\Exception\StorageErrorException;
56
use Memcached;
67
use Psr\Log\NullLogger;
78

@@ -38,7 +39,7 @@ protected function fixKey($key) {
3839
}
3940

4041
/**
41-
* @throws \Exception
42+
* @throws StorageErrorException
4243
*/
4344
protected function lazyLoadMemCachedServers()
4445
{
@@ -50,7 +51,7 @@ protected function lazyLoadMemCachedServers()
5051

5152
$stats = $this->memCached->getStats();
5253
if (!isset($stats[$server]) || $stats[$server]['pid'] === -1) {
53-
throw new \Exception("Memcached server $server is down");
54+
throw new StorageErrorException("Memcached server $server is down");
5455
}
5556
}
5657
}
@@ -60,7 +61,7 @@ protected function lazyLoadMemCachedServers()
6061
* @param string $key The object KEY
6162
* @param int $default IGNORED IN MEMCACHED.
6263
* @return mixed Description
63-
* @throws \Exception
64+
* @throws StorageErrorException
6465
*/
6566
public function get($key, $default = null)
6667
{
@@ -80,7 +81,7 @@ public function get($key, $default = null)
8081
* @param object $value The object to be cached
8182
* @param int $ttl The time to live in seconds of this objects
8283
* @return bool If the object is successfully posted
83-
* @throws \Exception
84+
* @throws StorageErrorException
8485
*/
8586
public function set($key, $value, $ttl = null)
8687
{
@@ -98,7 +99,7 @@ public function set($key, $value, $ttl = null)
9899
/**
99100
* @param string $key
100101
* @return bool
101-
* @throws \Exception
102+
* @throws StorageErrorException
102103
*/
103104
public function delete($key)
104105
{
@@ -117,14 +118,14 @@ public function isAvailable()
117118
try {
118119
$this->lazyLoadMemCachedServers();
119120
return true;
120-
} catch (\Exception $ex) {
121+
} catch (StorageErrorException $ex) {
121122
return false;
122123
}
123124
}
124125

125126
/**
126127
* @return bool
127-
* @throws \Exception
128+
* @throws StorageErrorException
128129
*/
129130
public function clear()
130131
{
@@ -136,7 +137,7 @@ public function clear()
136137
/**
137138
* @param string $key
138139
* @return bool
139-
* @throws \Exception
140+
* @throws StorageErrorException
140141
*/
141142
public function has($key)
142143
{

src/Psr16/ShmopCacheEngine.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace ByJG\Cache\Psr16;
44

5-
use Psr\Cache\InvalidArgumentException;
5+
use ByJG\Cache\Exception\InvalidArgumentException;
6+
use ByJG\Cache\Exception\StorageErrorException;
67
use Psr\Log\NullLogger;
78

89
/**
@@ -125,6 +126,7 @@ protected function isValidAge($file)
125126
* for it or let the driver take care of that.
126127
* @return bool True on success and false on failure.
127128
* @throws InvalidArgumentException
129+
* @throws StorageErrorException
128130
*/
129131
public function set($key, $value, $ttl = null)
130132
{
@@ -136,7 +138,7 @@ public function set($key, $value, $ttl = null)
136138
$size = strlen($serialized);
137139

138140
if ($size > $this->getMaxSize()) {
139-
throw new \ByJG\Cache\InvalidArgumentException('Object is greater than the max size allowed: ' . $this->getMaxSize());
141+
throw new StorageErrorException('Object is greater than the max size allowed: ' . $this->getMaxSize());
140142
}
141143

142144
$file = $this->getFilenameToken($key);
@@ -148,7 +150,7 @@ public function set($key, $value, $ttl = null)
148150
if (isset($lastError['message'])) {
149151
$message = $lastError['message'];
150152
}
151-
throw new \ByJG\Cache\InvalidArgumentException($message);
153+
throw new StorageErrorException($message);
152154
}
153155

154156
$shm_bytes_written = shmop_write($shm_id, $serialized, 0);

src/Psr6/CachePool.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace ByJG\Cache\Psr6;
44

5+
use ByJG\Cache\Exception\InvalidArgumentException;
56
use ByJG\Cache\Psr16\BaseCacheEngine;
67
use Psr\Cache\CacheItemInterface;
78
use Psr\Cache\CacheItemPoolInterface;
8-
use Psr\Log\InvalidArgumentException;
99

1010
class CachePool implements CacheItemPoolInterface
1111
{
@@ -204,7 +204,6 @@ public function deleteItems(array $keys)
204204
* @param CacheItemInterface $item
205205
* @return bool
206206
* @throws \Psr\SimpleCache\InvalidArgumentException
207-
* @throws \Psr\SimpleCache\InvalidArgumentException
208207
*/
209208
public function save(CacheItemInterface $item)
210209
{

0 commit comments

Comments
 (0)