Tweaked docs on letting Riak generate IDs
This commit is contained in:
@@ -115,22 +115,26 @@ public class Example {
|
||||
|
||||
<para>Additionally, there is a <literal>setWithMetaData</literal> method that takes a <classname>Map</classname> of metadata that will be set as the outgoing HTTP headers. To set <ulink url="https://wiki.basho.com/display/RIAK/REST+API#RESTAPI-Storeaneworexistingobjectwithakey">custom metadata</ulink>, your key should be prefixed with <literal>X-Riak-Meta-</literal> e.g. <literal>X-Riak-Meta-Custom-Header</literal>.</para>
|
||||
|
||||
<para>Riak has the ability to generate random IDs for you when storing objects. The <classname>RiakTemplate</classname> exposes this capability via the <literal>put</literal> method. It will return the ID it generated for you as a <classname>String</classname>.
|
||||
<programlisting language="java"><![CDATA[import org.springframework.data.keyvalue.riak.core.RiakTemplate;
|
||||
<section id="riak:template:objects:set:genid">
|
||||
<title>Letting Riak generate the key</title>
|
||||
|
||||
<para>Riak has the ability to generate random IDs for you when storing objects. The <classname>RiakTemplate</classname> exposes this capability via the <literal>put</literal> method. It will return the ID it generated for you as a <classname>String</classname>.
|
||||
<programlisting language="java"><![CDATA[import org.springframework.data.keyvalue.riak.core.RiakTemplate;
|
||||
|
||||
public class Example {
|
||||
|
||||
@Autowired
|
||||
RiakTemplate riak;
|
||||
|
||||
public String setData(String bucket, String key, String data) throws Exception {
|
||||
public String setData(String bucket, String data) throws Exception {
|
||||
String id = riak.put(bucket, data); // Returns the generated ID
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
]]></programlisting>
|
||||
</para>
|
||||
]]></programlisting>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="riak:template:objects:get">
|
||||
|
||||
Reference in New Issue
Block a user