2 Getting Started - Reference Documentation
Authors: Graeme Rocher
Version: 5.0.8.RELEASE
2 Getting Started
To get started with GORM for Redis you need to add the Redis GORM plugin as a dependency inbuild.gradle
:compile "org.grails.plugins:redis-gorm:VERSION"
redis-2.0.0
directory:make ./redis-server
[66243] 03 Sep 17:35:12 * Server started, Redis version 2.0.0 [66243] 03 Sep 17:35:12 * DB loaded from disk: 0 seconds [66243] 03 Sep 17:35:12 * The server is now ready to accept connections on port 6379
grails-app/conf/application.yml
:grails: redis-gorm: host: "myserver" port: 6380 password: "secret" pooled: true resources: 15 timeout: 5000
2.1 Using Redis Standalone
If you plan to use Redis as your primary datastore then you need to remove the Hibernate plugin definition frombuild.gradle
.compile "org.grails.plugins:hibernate"
create-domain-class
command:grails create-domain-class Person
Person
domain class will automatically be a persistent entity that can be stored in Redis.
2.2 Combining Redis and Hibernate
If you have both the Hibernate and Redis plugins installed then by default all classes in thegrails-app/domain
directory will be persisted by Hibernate and not Redis. If you want to persist a particular domain class with Redis then you must use the mapWith
property in the domain class:static mapWith = "redis"