4. YET ANOTHER ORM
It’s an object relational model (ORM) like ActiveRecord,
Mongoid, or DataMapper.
Ampere : Redis :: Mongoid : MongoDB :: ActiveRecord : SQL
Tuesday, October 2, 12
6. WHAT’S REDIS?
• Super-fast data cache, like memcached, but awesome.
6
Tuesday, October 2, 12
7. WHAT’S REDIS?
• Super-fast data cache, like memcached, but awesome.
• Durable. Your data’s still there even after a restart.
7
Tuesday, October 2, 12
8. WHAT’S REDIS?
• Super-fast data cache, like memcached, but awesome.
• Durable. Your data’s still there even after a restart.
• Supports more complex data structures like lists, sets, and
hashes.
8
Tuesday, October 2, 12
9. WHAT’S REDIS?
• Super-fast data cache, like memcached, but awesome.
• Durable. Your data’s still there even after a restart.
• Supports more complex data structures like lists, sets, and
hashes.
• Pub/sub event-driven magic.
9
Tuesday, October 2, 12
10. WHAT’S REDIS?
• Super-fast data cache, like memcached, but awesome.
• Durable. Your data’s still there even after a restart.
• Supports more complex data structures like lists, sets, and
hashes.
• Pub/sub event-driven magic.
• Scriptable in Lua (like anyone cares).
10
Tuesday, October 2, 12
11. A PEEK INSIDE AMPERE
How, exactly, does the magic happen?
Tuesday, October 2, 12
12. post.1
Post
{
title: “Hello World”,
body: “Hi everybody.”
}
AMPERE AT WORK
Ampere stores models as Hashes in Redis at keys defined by
the class name.
Tuesday, October 2, 12
13. post.1 post.1.comments
Post Comment
{
title: “Hello World”,
body: “Hi everybody.”
}
AMPERE AT WORK
Relationships are stored in Redis as Sets of IDs.
Tuesday, October 2, 12
14. post.1 post.1.comments
Post Comment
Comment
{
title: “Hello World”,
body: “Hi everybody.”
}
AMPERE AT WORK
Relationships are stored in Redis as Sets of IDs.
Tuesday, October 2, 12
15. post.1 post.1.comments
Post Comment
Comment
Comment
{
title: “Hello World”,
body: “Hi everybody.”
}
AMPERE AT WORK
Relationships are stored in Redis as Sets of IDs.
Tuesday, October 2, 12
16. post.1 post.1.comments
Post Comment
Comment
Comment
Comment
{
title: “Hello World”,
body: “Hi everybody.”
}
AMPERE AT WORK
Relationships are stored in Redis as Sets of IDs.
Tuesday, October 2, 12
17. USING AMPERE
Roll your own awesome.
Tuesday, October 2, 12
18. USING AMPERE
Roll your own awesome.
• Define fields with the field
method
Tuesday, October 2, 12
19. USING AMPERE
Roll your own awesome.
• Define fields with the field
method
• Store whatever kind of data you
want as long as it can be
marshaled
Tuesday, October 2, 12
20. USING AMPERE
Roll your own awesome.
• Define fields with the field
method
• Store whatever kind of data you
want as long as it can be
marshaled
• Use has_one, has_many, and
belongs_to as usual
Tuesday, October 2, 12
21. USING AMPERE
Roll your own awesome.
• Define fields with the field
method
• Store whatever kind of data you
want as long as it can be
marshaled
• Use has_one, has_many, and
belongs_to as usual
• That’s it. (Srsly.)
Tuesday, October 2, 12
22. UNDER CONSTRUCTION
Ampere is under active development.
There’s still more awesome to come.
Tuesday, October 2, 12
23. Here are some links
For tracking me down
http://github.com/mstahl max@villainousindustri.es
http://twitter.com/villainous
For learning about Redis
http://redis.io/
23
Tuesday, October 2, 12