I have a very simple test case I am using to try to understand redis. I did install-plugin redis-gorm.
Domain Object:
class BenchGroup {
String groupName
/*static mapWith = "redis"
static mapping = {
groupName(index:true)
}*/
static constraints = {
}
}
Bootstrap Code:
def everyoneGroup = new BenchGroup(groupName:'everyoneGroup')
everyoneGroup.save()
if(everyoneGroup.hasErrors()){
println everyoneGroup.errors
}
println everyoneGroup
def dammit = BenchGroup.findByGroupName('everyoneGroup')
println dammit
When I leave the redis map line commented it uses HSQL and outputs this:
stupidbenchmarks.BenchGroup : 2
stupidbenchmarks.BenchGroup : 2
When I switch to redis it does this:
stupidbenchmarks.BenchGroup : 2
null
i.e. .findBy doesn’t work.
Hibernate flushes before doing queries (in this case
findByGroupName) but the NoSQL GORM Datastore implementations don’t (yet) so I assume you just need a flush to push the saved instance to the datastore so the query picks it up: