Chapter 4. Advanced Operations
So far you have looked at Aerospike’s basic operations, primarily reading and writing data. We have discussed how data is stored in bins and that multiple bins can be read or written in a single call. What you’re going to look at now is some operations that go beyond those basics.
First, you’ll look at a few of the many capabilities of the operate() command. In particular, you’ll see how to add, append, and update data in some of the more complex data types such as lists and maps. Then, you’ll learn some of the basics of how to use expressions to create conditional writes and derived reads, among other interesting data operations. You’ll be introduced to more advanced batch operations, secondary indexes, multiple predicate queries, and a host of other aspects of using Aerospike.
The operate() Command
One of the most powerful commands on a single record is the operate() command. In fact, it is so powerful that all other single record commands are just syntactic sugar that wrap the operate() command. If you have been following along with the examples in this book so far, you have actually used this command, albeit wrapped in a get() or put() method.
operate() allows you to perform an arbitrary complex list of operations on a single record, taking a list of Operation classes containing the appropriate actions. So for example, in a single call, you could insert one bin, add 10 to the contents of another bin, work out the size of a map in a third bin, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access