@@ -14,10 +14,12 @@ compliant requests that can be used as well as high level abstractions to ease d
1414 - [ Hard Dependencies] ( #hard-dependencies )
1515 - [ Optional Dependencies] ( #optional-dependencies )
1616- [ Installation] ( #installation )
17+ - [ Compatibility] ( #compatibility )
1718- [ Usage] ( #usage )
1819 - [ Asynchronous API] ( #asynchronous-api )
1920 - [ Synchronous API] ( #synchronous-api )
2021 - [ Caching] ( #caching )
22+ - [ Low Level API] ( #low-level-api )
2123- [ Testing] ( #testing )
2224 - [ Unit tests, Coding standards and static analysis] ( #unit-tests-coding-standards-and-static-analysis )
2325 - [ Integration tests] ( #integration-tests )
@@ -30,7 +32,7 @@ compliant requests that can be used as well as high level abstractions to ease d
3032| Dependency | Version | Reason |
3133| :--- | :---:| :--- |
3234| ** ` php ` ** | ~ 7.0 | Anything lower has reached EOL |
33- | ** ` guzzlephp/guzzle ` ** | ~ 6.2 | Using ` Request ` to build PSR-7 ` RequestInterface ` |
35+ | ** ` guzzlephp/guzzle ` ** | ~ 6.3 | Using ` Request ` to build PSR-7 ` RequestInterface ` |
3436| ** ` beberlei/assert ` ** | ~ 2.7 | The de-facto standard assertions library for PHP |
3537| ** ` rg/avro-php ` ** | ~ 1.8 | The only Avro PHP implementation I have found so far. |
3638
@@ -46,9 +48,15 @@ compliant requests that can be used as well as high level abstractions to ease d
4648This library is installed via [ ` composer ` ] ( http://getcomposer.org ) .
4749
4850``` bash
49- composer require " flix-tech/confluent-schema-registry-api=~3 .0"
51+ composer require " flix-tech/confluent-schema-registry-api=~4 .0"
5052```
5153
54+ ## Compatibility
55+
56+ This library follows strict semantic versioning, so you can expect any minor and patch release to be compatible, while
57+ major version upgrades will have incompatibilities that will be released in the UPGRADE.md file.
58+
59+
5260## Usage
5361
5462### Asynchronous API
@@ -153,6 +161,11 @@ $schemaId = $registry->register('test-subject', $schema);
153161There is a ` CachedRegistry ` that accepts a ` CacheAdapter ` together with a ` Registry ` .
154162It supports both async and sync APIs.
155163
164+ > ** NOTE:**
165+ >
166+ > From version 4.x of this library the API for the ` CacheAdapterInterface ` has been changed in order to allow caching
167+ > of schema ids by hash of a given schema.
168+
156169#### Example
157170
158171``` php
@@ -173,7 +186,7 @@ $asyncApi = new PromisingRegistry(
173186$syncApi = new BlockingRegistry($asyncApi);
174187
175188$doctrineCachedSyncApi = new CachedRegistry(
176- $syncApi ,
189+ $asyncApi ,
177190 new DoctrineCacheAdapter(
178191 new ArrayCache()
179192 )
@@ -184,8 +197,33 @@ $avroObjectCachedAsyncApi = new CachedRegistry(
184197 $syncApi,
185198 new AvroObjectCacheAdapter()
186199);
200+
201+ // NEW in version 4.x, passing in custom hash functions to cache schema ids via the schema hash
202+ // By default the following function is used internally
203+ $defaultHashFunction = function (AvroSchema $schema) {
204+ return md5((string) $schema);
205+ };
206+
207+ // You can also define your own hash callable
208+ $sha1HashFunction = function (AvroSchema $schema) {
209+ return sha1((string) $schema);
210+ };
211+
212+ // Pass the hash function as optional 3rd parameter to the CachedRegistry constructor
213+ $avroObjectCachedAsyncApi = new CachedRegistry(
214+ $syncApi,
215+ new AvroObjectCacheAdapter(),
216+ $sha1HashFunction
217+ );
187218```
188219
220+ ### Low Level API
221+
222+ There is a low-level API that provides simple functions that return PSR-7 request objects for the different endpoints of
223+ the registry. See [ Requests/Functions] ( src/Requests/Functions.php ) for more information.
224+
225+ There are also requests to use the new ` DELETE ` API of the schema registry.
226+
189227## Testing
190228
191229This library uses a ` Makefile ` to run the test suite.
0 commit comments