You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ Porter's API
118
118
Porter's asynchronous API mirrors the synchronous one with similar method names but different signatures.
119
119
120
120
*`importAsync(AsyncImportSpecification): AsyncPorterRecords|CountableAsyncPorterRecords`– Imports one or more records asynchronously from the resource contained in the specified asynchronous import specification.
121
-
*`importOneAsync(AsyncImportSpecification): Promise`– Imports one record from the resource contained in the specified asynchronous import specification.
121
+
*`importOneAsync(AsyncImportSpecification): Promise<array>`– Imports one record from the resource contained in the specified asynchronous import specification.
122
122
123
123
Overview
124
124
--------
@@ -250,10 +250,12 @@ Durability only applies when connectors throw a recoverable exception type deriv
250
250
Caching
251
251
-------
252
252
253
-
Any connector can be wrapped in a `CachingConnector` to provide [PSR-6][] caching facilities to the base connector. Porter ships with one cache implementation, `MemoryCache`, which caches fetched data in memory, but this can be substituted for any other PSR-6 cache implementation. The `CachingConnector` caches raw responses for each unique [cache key](#cache-keys).
253
+
Any connector can be wrapped in a `CachingConnector` to provide [PSR-6][] caching facilities to the base connector. Porter ships with one cache implementation, `MemoryCache`, which caches fetched data in memory, but this can be substituted for any other PSR-6 cache implementation. The `CachingConnector` caches raw responses for each unique request, where uniqueness is determined by `DataSource::computeHash`.
254
254
255
255
Remember that whilst using a `CachingConnector` enables caching, caching must also be enabled on a per-import basis by calling `ImportSpecification::enableCache()`.
256
256
257
+
Note that Caching is not yet supported for asynchronous imports.
258
+
257
259
### Example
258
260
259
261
The follow example enables connector caching.
@@ -283,7 +285,7 @@ The rest of this readme is for those wishing to go deeper. Continue when you're
283
285
Architecture
284
286
------------
285
287
286
-
The following UML class diagram shows a partial architectural overview illustrating Porter's main components and how they are related. [[enlarge][Class diagram]]
288
+
The following UML class diagram shows a partial architectural overview illustrating Porter's main components and how they are related. Asynchronous implementation details are mostly omitted since they mirror the synchronous system. [[enlarge][Class diagram]]
287
289
288
290
[![Class diagram][]][Class diagram]
289
291
@@ -330,7 +332,7 @@ Resources fetch data using the supplied connector and format it as a collection
330
332
331
333
```php
332
334
public function getProviderClassName(): string;
333
-
public function fetch(ImportConnector $connector): Iterator;
335
+
public function fetch(ImportConnector $connector): \Iterator;
334
336
```
335
337
336
338
A resource supplies the class name of the provider it expects a connector from when `getProviderClassName()` is called.
@@ -348,7 +350,7 @@ Resources must implement the `ProviderResource` interface. `getProviderClassName
348
350
In this contrived example that uses dummy data and ignores the connector, suppose we want to return the numeric series one to three: the following implementation would be invalid because it returns an iterator of integer values instead of an iterator of array values.
349
351
350
352
```php
351
-
public function fetch(ImportConnector $connector)
353
+
public function fetch(ImportConnector $connector): \Iterator
352
354
{
353
355
return new ArrayIterator(range(1, 3)); // Invalid return type.
354
356
}
@@ -357,7 +359,7 @@ public function fetch(ImportConnector $connector)
357
359
Either of the following `fetch()` implementations would be valid.
358
360
359
361
```php
360
-
public function fetch(ImportConnector $connector)
362
+
public function fetch(ImportConnector $connector): \Iterator
361
363
{
362
364
foreach (range(1, 3) as $number) {
363
365
yield [$number];
@@ -368,7 +370,7 @@ public function fetch(ImportConnector $connector)
368
370
Since the total number of records is known, the iterator can be wrapped in `CountableProviderRecords` to enrich the caller with this information.
369
371
370
372
```php
371
-
public function fetch(ImportConnector $connector)
373
+
public function fetch(ImportConnector $connector): \Iterator
372
374
{
373
375
$series = function ($limit) {
374
376
foreach (range(1, $limit) as $number) {
@@ -515,7 +517,7 @@ Porter is published under the open source GNU Lesser General Public License v3.0
0 commit comments