riak-shim 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +37 -0
- data/lib/riak-shim/persistable.rb +5 -0
- data/lib/riak-shim/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -4,6 +4,8 @@ A teeny shim between your code and the riak-client gem. Reads database configur
|
|
4
4
|
out of config/database.yml and derives bucket names from your class names and an
|
5
5
|
appropriate prefix.
|
6
6
|
|
7
|
+
Riak is a database from the good people at Basho. Check it out: http://basho.com/products/riak-overview/
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -20,7 +22,38 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
25
|
+
Create a config/database.yml containing the details of your Riak like so:
|
26
|
+
|
27
|
+
development: &default
|
28
|
+
bucket_prefix: dev_
|
29
|
+
host: localhost
|
30
|
+
http_port: 8098
|
31
|
+
|
32
|
+
test:
|
33
|
+
<<: *default
|
34
|
+
bucket_prefix: test_
|
35
|
+
|
36
|
+
In any class you wish to persist:
|
37
|
+
include Riak::Shim::Persistable
|
38
|
+
|
39
|
+
def to_hash
|
40
|
+
# Return hashified version of your class
|
41
|
+
end
|
42
|
+
|
43
|
+
def fields_to_index
|
44
|
+
# Return an Array of hash keys you would like placed into a secondary index.
|
45
|
+
# Return an empty Array if you don't know what this means. :)
|
46
|
+
end
|
23
47
|
|
48
|
+
Now you can save instances of that class by calling #save on them and retrieve them from Riak by calling
|
49
|
+
|
50
|
+
YourClass.for_index(index_name, value)
|
51
|
+
|
52
|
+
Where `index_name` is what you defined in `fields_to_index` plus the suffix "_bin" .
|
53
|
+
|
54
|
+
The `value` is what you want to look up.
|
55
|
+
|
56
|
+
Return value is an Array of instances of your class matching the query.
|
24
57
|
|
25
58
|
## Contributing
|
26
59
|
|
@@ -29,3 +62,7 @@ Or install it yourself as:
|
|
29
62
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
63
|
4. Push to the branch (`git push origin my-new-feature`)
|
31
64
|
5. Create new Pull Request
|
65
|
+
|
66
|
+
## TODOS
|
67
|
+
|
68
|
+
- Implement a #for_key lookup method.
|
data/lib/riak-shim/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riak-shim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Brodhead & Shai Rosenfeld
|