Skip to content

Commit 65fc071

Browse files
committed
Removed "cache keys" section from readme.
1 parent 473c9c9 commit 65fc071

2 files changed

Lines changed: 11 additions & 36 deletions

File tree

README.md

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ Porter includes one transformer, `FilterTransformer`, that removes records from
174174
Transformers implement the `Transformer` interface that defines one method with the following signature.
175175

176176
```php
177-
public function transform(RecordCollection $records, $context) : RecordCollection;
177+
public function transform(RecordCollection $records, $context): RecordCollection;
178178
```
179179

180180
When `transform()` is called the transformer may iterate each record and change it in any way, including removing or inserting additional records. The record collection must be returned by the method, whether or not changes were made.
181181

182-
Transformers should also implement the `__clone` magic method if the they store any object state in order to facilitate deep copy when Porter clones the owning `ImportSpecification` during an import.
182+
Transformers should also implement the `__clone` magic method if the they store any object state, in order to facilitate deep copy when Porter clones the owning `ImportSpecification` during import.
183183

184184
Filtering
185185
---------
@@ -188,7 +188,7 @@ Filtering provides a way to remove some records. For each record, if the specifi
188188

189189
In general we would like to avoid filtering because it is inefficient to import data and then immediately remove some of it, but some immature APIs do not provide a way to reduce the data set on the server, so filtering on the client is the only alternative. Filtering also invalidates the record count reported by some resources, meaning we no longer know how many records are in the collection before iteration.
190190

191-
#### Example
191+
### Example
192192

193193
The following example filters out any records that do not have an *id* field present.
194194

@@ -225,7 +225,7 @@ Any connector can be wrapped in a `CachingConnector` to provide [PSR-6][PSR-6] c
225225

226226
Remember that whilst using a `CachingConnector` enables caching, caching must also be enabled on a per-import basis by calling `ImportSpecification::enableCache()`.
227227

228-
#### Example
228+
### Example
229229

230230
The follow example enables connector caching.
231231

@@ -236,34 +236,6 @@ $records = $porter->import(
236236
);
237237
```
238238

239-
### Cache keys
240-
241-
The cache key is generated by a `CacheKeyGenerator` that encodes the source and connector options to produce a unique cache key for each distinct `Connector::fetch` request. The default `JsonCacheKeyGenerator` simply JSON-encodes the parameters to create a cache key. The cache key generation strategy may be changed by calling `CachingConnector::setCacheKeyGenerator`.
242-
243-
#### Writing a cache key generator
244-
245-
The `CacheKeyGenerator` interface defines one method with the following interface.
246-
247-
```php
248-
public function generateCacheKey(string $source, array $sortedOptions) : string;
249-
```
250-
251-
Implementations receive the source of the fetch request and an array and sorted options, so that options originally specified in a different order still result in the same cache key. The method must return a [PSR-6][PSR-6] compatible cache key.
252-
253-
##### Implementation example
254-
255-
The following example demonstrates cache key generation using a hash of JSON-encoded parameters.
256-
257-
```php
258-
class MyCacheKeyGenerator implements CacheKeyGenerator
259-
{
260-
public function generateCacheKey($source, array $sortedOptions)
261-
{
262-
return md5(json_encode([$source, $optionsSorted]));
263-
}
264-
}
265-
```
266-
267239
---
268240

269241
<div align="center">
@@ -273,7 +245,7 @@ INTERMISSION
273245

274246
Congratulations! We have covered everything needed to use Porter.
275247

276-
The rest of this readme is for those wishing to go deeper. Continue when you're ready to learn how to write [providers](#providers), [resources](#resources) and [connectors](#connectors).
248+
The rest of this readme is for those wishing to go deeper. Continue when you're ready to learn how to write [providers](#providers), [resources](#resources) and [connectors](#connectors). ☕️
277249

278250
</div>
279251

@@ -328,8 +300,8 @@ Resources
328300
Resources fetch data using the supplied connector and format it as a collection of arrays. A resource implements `ProviderResource` that defines the following three methods.
329301

330302
```php
331-
public function getProviderClassName() : string;
332-
public function fetch(ImportConnector $connector) : Iterator;
303+
public function getProviderClassName(): string;
304+
public function fetch(ImportConnector $connector): Iterator;
333305
```
334306

335307
A resource supplies the class name of the provider it expects a connector from when `getProviderClassName()` is called.
@@ -447,7 +419,7 @@ Connectors fetch remote data from a source specified at fetch time. Connectors f
447419
Writing providers and resources is a common task that should be fairly easy but writing a connector is slightly less common and has some specific technical considerations that must be carefully considered. A connector implements the `Connector` interface that defines one method with the following signature.
448420

449421
```php
450-
public function fetch(ConnectionContext $context, $source) : mixed;
422+
public function fetch(ConnectionContext $context, $source): mixed;
451423
```
452424

453425
When `fetch()` is called the connector fetches data from the specified source. Connectors may return data in any format that's convenient for resources to consume, but in general, such data should be as raw as possible and without modification. If multiple pieces of information are returned it is recommended to use a specialized response class, like the HTTP connector that returns the response body and headers together in an `HttpResponse`.

docs/Quickstart.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Porter Quick Start Guide
2+
========================
3+
14
This quick start guide will walk through getting up and running with Porter from scratch and assumes you already have a PHP environment set up with Composer. Let's start by initializing our Composer file by running `composer init` in our project's root directory and accepting the defaults. We can skip defining dependencies interactively because we'll issue separate commands in a moment.
25

36
Let's start with the [European Central Bank][ECB provider] (ECB) provider by including it in our `composer.json` with the following command.

0 commit comments

Comments
 (0)