diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index c5c1fdb..7351684 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -1,9 +1,10 @@ = Spring Data Key-Value Reference Guide -Oliver Gierke; Thomas Darimont; Christoph Strobl; Jay Bryant +Oliver Gierke; Thomas Darimont; Christoph Strobl; Jay Bryant; Mark Paluch :revnumber: {version} :revdate: {localdate} ifdef::backend-epub3[:front-cover-image: image:epub-cover.png[Front Cover,1050,1600]] :spring-data-commons-docs: https://raw.githubusercontent.com/spring-projects/spring-data-commons/master/src/main/asciidoc +:spring-data-keyvalue-docs: https://docs.spring.io/spring-data/keyvalue/docs/{version}/api/ :spring-framework-docs: https://docs.spring.io/spring-framework/docs/{springVersion}/spring-framework-reference/ (C) 2008-2021 The original authors. diff --git a/src/main/asciidoc/key-value-repositories.adoc b/src/main/asciidoc/key-value-repositories.adoc index 9b20b9f..88ba715 100644 --- a/src/main/asciidoc/key-value-repositories.adoc +++ b/src/main/asciidoc/key-value-repositories.adoc @@ -46,22 +46,29 @@ In its very basic shape, the `KeyValueTemplate` uses a `MapAdapter` that wraps a NOTE: The used `KeyValueAdapter` does the heavy lifting when it comes to storing and retrieving data. The data structure influences performance and multi-threading behavior. -You can use a different type or preinitialize the adapter with some values, and you can do so by using various constructors on `MapKeyValueAdapter`, as the following example shows: +You can use a different type or pre-initialize the adapter with some values, and you can do so by using various constructors on `MapKeyValueAdapter`, as the following example shows: +==== [source, java] ---- -@Bean -public KeyValueOperations mapKeyValueTemplate() { - return new KeyValueTemplate(keyValueAdapter()); -} +@EnableMapRepositories +@Configuration +class MyConfiguration { -@Bean -public KeyValueAdapter keyValueAdapter() { - return new MapKeyValueAdapter(ConcurrentHashMap.class); + @Bean + public KeyValueOperations mapKeyValueTemplate() { <1> + return new KeyValueTemplate(keyValueAdapter()); + } + + @Bean + public KeyValueAdapter keyValueAdapter() { + return new MapKeyValueAdapter(ConcurrentHashMap.class); <2> + } } ---- - -Alternatively, you might use `@EnableMapRepositories(keyValueTemplateRef=…)`. +<1> Defines a custom `KeyValueOperations` bean using the default bean name. See documentation and properties of {spring-data-keyvalue-docs}org/springframework/data/map/repository/config/EnableMapRepositories.html[`@EnableMapRepositories`] for further customization. +<2> Defines a custom `KeyValueAdapter` bean using a `ConcurrentHashMap` as storage that is used by `KeyValueTemplate`. +==== [[key-value.keyspaces]] == Keyspaces