Skip to content

Commit b495651

Browse files
authored
Merge pull request #10 from wp-oop/fix/7-return-value-incompat
Add PSR-16 Exception Compatible Pool Wrapper
2 parents 6121504 + 5f2e663 commit b495651

File tree

10 files changed

+708
-32
lines changed

10 files changed

+708
-32
lines changed

.gitattributes

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
test export-ignore
2-
nbproject export-ignore
1+
tests export-ignore
32
.idea export-ignore
4-
.codeclimate.yml export-ignore
5-
.php_cs export-ignore
3+
docker export-ignore
4+
docker-compose.yml export-ignore
5+
.env.example export-ignore
66
.travis.yml export-ignore
77
.gitattributes export-ignore
88
.gitignore export-ignore
99
composer.lock export-ignore
1010
phpunit.xml export-ignore
11-
.env
12-
.env.example

.idea/sqldialects.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [[*next-version*]] - YYYY-MM-DD
8+
### Fixed
9+
- False-negative check used to confirm the negative because of wrong option name.
10+
- Non-getter interface methods of `CachePool` now return `true` on success.
11+
- Non-getter interface methods of `CachePool` now declare and throw proper exceptions.
12+
13+
### Added
14+
- `SilentPool`, which wraps cache pools that throw non-PSR-16 exceptions and suppress them, making the pool compatible (#7).
15+
- Missing documentation.
16+
17+
### Changed
18+
- Centralized behaviour like option deletion, and option/transient retrieval/assignment.
819

920
## [0.1.0-alpha1] - 2020-04-14
1021
Initial version.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ transients as storage. Exceptions are raised, interfaces implemented, and true f
2323
Each instance of the cache pool is logically independent from other instances, provided that it is given a unique
2424
name. The application is once again in control, and modules that use cache can become platform agnostic.
2525

26+
### Compatibility
27+
- `CachePool` and `CachePoolFactory` offer best-practices error handling, throwing meaningful exceptions
28+
when something goes wrong. This violates PSR-16, but allows you to know what is failing.
29+
- `SilentPool` and `SilentPoolFactory` offer PSR-16 compatibility at the cost of error handling,
30+
hiding exceptions, and returning standards-compatible values. This complies with PSR-16, but at the cost of
31+
clarity and verbosity.
32+
2633
### Usage
2734
```php
2835
/*
@@ -31,10 +38,12 @@ name. The application is once again in control, and modules that use cache can b
3138
use wpdb;
3239
use Psr\SimpleCache\CacheInterface;
3340
use WpOop\TransientCache\CachePoolFactory;
41+
use WpOop\TransientCache\SilentPoolFactory;
3442

3543
/* @var $wpdb wpdb */
3644
$factory = new CachePoolFactory($wpdb);
37-
45+
// Optionally hide exceptions for PSR-16 compatibility
46+
$factory = new SilentPoolFactory($factory); // Optional, and not recommended for testing environments!
3847

3948
/*
4049
* Create cache pools - usually somewhere else

0 commit comments

Comments
 (0)