5 Transactions - Reference Documentation
Authors: Graeme Rocher
Version: 5.0.0.BUILD-SNAPSHOT
5 Transactions
Transactions in Redis (using MULTI/EXEC) operate differently to SQL transactions. In fact they are more a way to do bulk operations that can be discarded rather than full transactions (see the documentation on MULTI/EXEC for further information).One limitation of Redis' MULT/EXEC command is that even reads are batched up in the transaction. This trickles down to usage within GORM for Redis. So for example you can execute a transaction such as:Person.withTransaction { new Person(firstName:"Bob").save() new Person(firstName:"Fred").save() }
Person.withTransaction { new Person(firstName:"Bob").save() def fred Person.withNewSession { fred = Person.findByFirstName("Fred") } if (!fred) { new Person(firstName:"Fred").save() } }
withNewSession
method.