Skip to content

Commit

Permalink
Expand documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Aug 12, 2022
1 parent 4129e50 commit 864a6e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ composer require wyrihaximus/react-cache-psr-16-adapter

## Usage ##

Take any [`react/cache`](https://reactphp.org/cache/) implementation, like [`wyrihaximus/react-cache-redis `](https://github.com/WyriHaximus/reactphp-cache-redis) we'll be using in this example.
Take any [`react/cache`](https://reactphp.org/cache/) implementation, like
[`wyrihaximus/react-cache-redis `](https://github.com/WyriHaximus/reactphp-cache-redis) we'll be using in this example.
Decorate it with a `PSR16Adapter` instance, and you can use them as a PSR-16 cache within fibers. Directly, or with
other packages. Internally `PSR16Adapter` uses [`await`](https://reactphp.org/async/#await) on every method call to the
`react/cache` implementation to make it compatible.

```php
$cache = new PSR16Adapter(new Redis($reditClient, 'react:cache:your:key:prefix:'));

React\Async\async(function () {
$cache->set('key', 'value');
$cache->set('key', 'value'); // All methods use `await` internally to make any ReactPHP cache PSR-16 compatible
echo $cache->get('key'); // echos: value
})();
```
Expand Down

0 comments on commit 864a6e6

Please sign in to comment.