|
1 | | -.. ref-bucket: |
2 | | -
|
3 | | -========== |
4 | | -RiakBucket |
5 | | -========== |
| 1 | +======= |
| 2 | +Buckets |
| 3 | +======= |
6 | 4 |
|
7 | 5 | .. currentmodule:: riak.bucket |
8 | 6 |
|
9 | | -.. autoclass:: riak.bucket.RiakBucket |
| 7 | +Buckets are both namespaces for the key-value pairs you store in Riak, |
| 8 | +and containers for properties that apply to that namespace. Buckets |
| 9 | +should be created via the :meth:`bucket() |
| 10 | +<riak.client.RiakClient.bucket>` method on the client object, like so:: |
| 11 | + |
| 12 | + import riak |
| 13 | + |
| 14 | + client = riak.RiakClient() |
| 15 | + mybucket = client.bucket('mybucket') |
| 16 | + |
| 17 | +-------------- |
| 18 | +Bucket objects |
| 19 | +-------------- |
| 20 | + |
| 21 | +.. autoclass:: RiakBucket |
| 22 | + |
| 23 | + .. attribute:: name |
| 24 | + |
| 25 | + The name of the bucket, a string. |
| 26 | + |
| 27 | + .. autoattribute:: resolver |
| 28 | + |
| 29 | +----------------- |
| 30 | +Bucket properties |
| 31 | +----------------- |
| 32 | + |
| 33 | +Bucket properties are flags and defaults that apply to all keys in the |
| 34 | +bucket. |
| 35 | + |
| 36 | +.. automethod:: RiakBucket.get_properties |
| 37 | +.. automethod:: RiakBucket.set_properties |
| 38 | +.. automethod:: RiakBucket.clear_properties |
| 39 | +.. automethod:: RiakBucket.get_property |
| 40 | +.. automethod:: RiakBucket.set_property |
| 41 | + |
| 42 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 43 | +Shortcuts for common properties |
| 44 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 45 | + |
| 46 | +Some of the most commonly-used bucket properties are exposed as object |
| 47 | +properties as well. The getters and setters simply call |
| 48 | +:meth:`RiakBucket.get_property` and :meth:`RiakBucket.set_property` |
| 49 | +respectively. |
| 50 | + |
| 51 | +.. autoattribute:: RiakBucket.n_val |
| 52 | +.. autoattribute:: RiakBucket.allow_mult |
| 53 | +.. autoattribute:: RiakBucket.r |
| 54 | +.. autoattribute:: RiakBucket.pr |
| 55 | +.. autoattribute:: RiakBucket.w |
| 56 | +.. autoattribute:: RiakBucket.dw |
| 57 | +.. autoattribute:: RiakBucket.pw |
| 58 | +.. autoattribute:: RiakBucket.rw |
| 59 | + |
| 60 | +^^^^^^^^^^^^^^^^^^^^ |
| 61 | +Shortcuts for search |
| 62 | +^^^^^^^^^^^^^^^^^^^^ |
| 63 | + |
| 64 | +When Riak Search is enabled on the server, you can toggle which |
| 65 | +buckets have automatic indexing turned on using the ``search`` bucket |
| 66 | +property (and on older versions, the ``precommit`` property). These |
| 67 | +methods simplify interacting with that configuration. |
| 68 | + |
| 69 | +.. automethod:: RiakBucket.search_enabled |
| 70 | +.. automethod:: RiakBucket.enable_search |
| 71 | +.. automethod:: RiakBucket.disable_search |
| 72 | + |
| 73 | +----------------- |
| 74 | +Working with keys |
| 75 | +----------------- |
| 76 | + |
| 77 | +The primary purpose of buckets is to act as namespaces for keys. As |
| 78 | +such, you can use the bucket object to create, fetch and delete |
| 79 | +:class:`objects <riak.riak_object.RiakObject>`. |
| 80 | + |
| 81 | +.. automethod:: RiakBucket.new |
| 82 | +.. automethod:: RiakBucket.new_from_file |
| 83 | +.. automethod:: RiakBucket.get |
| 84 | +.. automethod:: RiakBucket.multiget |
| 85 | +.. automethod:: RiakBucket.delete |
| 86 | + |
| 87 | +.. _counters: |
| 88 | + |
| 89 | +^^^^^^^^ |
| 90 | +Counters |
| 91 | +^^^^^^^^ |
| 92 | + |
| 93 | +Rather than returning objects, the counter operations new to Riak 1.4 |
| 94 | +act directly on the value of the counter. |
| 95 | + |
| 96 | +.. automethod:: RiakBucket.get_counter |
| 97 | +.. automethod:: RiakBucket.update_counter |
| 98 | + |
| 99 | +---------------- |
| 100 | +Query operations |
| 101 | +---------------- |
| 102 | + |
| 103 | +.. automethod:: RiakBucket.search |
| 104 | +.. automethod:: RiakBucket.get_index |
| 105 | +.. automethod:: RiakBucket.stream_index |
| 106 | + |
| 107 | + |
| 108 | +------------- |
| 109 | +Serialization |
| 110 | +------------- |
| 111 | + |
| 112 | +Similar to :class:`RiakClient <riak.client.RiakClient>`, buckets can |
| 113 | +register custom transformation functions for media-types. When |
| 114 | +undefined on the bucket, :meth:`RiakBucket.get_encoder` and |
| 115 | +:meth:`RiakBucket.get_decoder` will delegate to the client associated |
| 116 | +with the bucket. |
| 117 | + |
| 118 | +.. automethod:: RiakBucket.get_encoder |
| 119 | +.. automethod:: RiakBucket.set_encoder |
| 120 | +.. automethod:: RiakBucket.get_decoder |
| 121 | +.. automethod:: RiakBucket.set_decoder |
| 122 | + |
| 123 | + |
| 124 | +------------ |
| 125 | +Listing keys |
| 126 | +------------ |
| 127 | + |
| 128 | +Shortcuts for :meth:`RiakClient.get_keys() |
| 129 | +<riak.client.RiakClient.get_keys>` and |
| 130 | +:meth:`RiakClient.stream_keys() |
| 131 | +<riak.client.RiakClient.stream_keys>` are exposed on the bucket |
| 132 | +object. The same admonitions for these operations apply. |
| 133 | + |
| 134 | +.. automethod:: RiakBucket.get_keys |
| 135 | +.. automethod:: RiakBucket.stream_keys |
| 136 | + |
| 137 | +------------------ |
| 138 | +Deprecated methods |
| 139 | +------------------ |
| 140 | + |
| 141 | +.. warning:: These methods exist solely for backwards-compatibility and should not |
| 142 | + be used unless code is being ported from an older version. |
| 143 | + |
| 144 | +.. automethod:: RiakBucket.new_binary |
| 145 | +.. automethod:: RiakBucket.new_binary_from_file |
| 146 | +.. automethod:: RiakBucket.get_binary |
| 147 | +.. automethod:: RiakBucket.get_r |
| 148 | +.. automethod:: RiakBucket.set_r |
| 149 | +.. automethod:: RiakBucket.get_pr |
| 150 | +.. automethod:: RiakBucket.set_pr |
| 151 | +.. automethod:: RiakBucket.get_w |
| 152 | +.. automethod:: RiakBucket.set_w |
| 153 | +.. automethod:: RiakBucket.get_dw |
| 154 | +.. automethod:: RiakBucket.set_dw |
| 155 | +.. automethod:: RiakBucket.get_pw |
| 156 | +.. automethod:: RiakBucket.set_pw |
| 157 | +.. automethod:: RiakBucket.get_rw |
| 158 | +.. automethod:: RiakBucket.set_rw |
0 commit comments