ohm 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +35 -0
- data/lib/ohm/lua/save.lua +3 -2
- data/ohm.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcac01f4679b94c4e17d2ee417f59887a8a41f62
|
4
|
+
data.tar.gz: 5fba56af15af361a22fd0cd6df37adf9bc9beaf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c011955d15f026470d4af58e1b4d96be6b685bee79aa3b85247640bc700268d80fb7ed3f258ac2055fea7fc0ff8bd2dd4b07869b466b5cd89acbfa03143c8bee
|
7
|
+
data.tar.gz: 7e7ed6334f0db7446262362a49540cee4bbce18ff1163992854dd6faac6cb7f99147f1b753552fdf4aa4ff84dbd678fb8b9ba19951a0ef4b7f640b2eaa35b857
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -222,6 +222,41 @@ containing the foreign key to another model.
|
|
222
222
|
|
223
223
|
Provides an accessor to search for all models that `reference` the current model.
|
224
224
|
|
225
|
+
Tracked keys
|
226
|
+
------------
|
227
|
+
|
228
|
+
Besides the provided attribute types, it is possible to instruct
|
229
|
+
Ohm to track arbitrary keys and tie them to the object's lifecycle.
|
230
|
+
|
231
|
+
For example:
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
class Log < Ohm::Model
|
235
|
+
track :text
|
236
|
+
|
237
|
+
def append(msg)
|
238
|
+
redis.call("APPEND", key[:text], msg)
|
239
|
+
end
|
240
|
+
|
241
|
+
def tail(n = 100)
|
242
|
+
redis.call("GETRANGE", key[:text], -(n), -1)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
log = Log.create
|
247
|
+
log.append("hello\n")
|
248
|
+
|
249
|
+
assert_equal "hello\n", log.tail
|
250
|
+
|
251
|
+
log.append("world\n")
|
252
|
+
|
253
|
+
assert_equal "world\n", log.tail(6)
|
254
|
+
```
|
255
|
+
|
256
|
+
When the `log` object is deleted, the `:text` key will be deleted
|
257
|
+
too. Note that the key is scoped to that particular instance of
|
258
|
+
`Log`, so if `log.id` is `42` then the key will be `Log:42:text`.
|
259
|
+
|
225
260
|
Persistence strategy
|
226
261
|
--------------------
|
227
262
|
|
data/lib/ohm/lua/save.lua
CHANGED
@@ -78,9 +78,10 @@ end
|
|
78
78
|
local function unique(model, uniques)
|
79
79
|
for field, value in pairs(uniques) do
|
80
80
|
local key = model.name .. ":uniques:" .. field
|
81
|
+
local val = tostring(value)
|
81
82
|
|
82
|
-
redis.call("HSET", model.key .. ":_uniques", key,
|
83
|
-
redis.call("HSET", key,
|
83
|
+
redis.call("HSET", model.key .. ":_uniques", key, val)
|
84
|
+
redis.call("HSET", key, val, model.id)
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
data/ohm.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ohm"
|
3
|
-
s.version = "3.0.
|
3
|
+
s.version = "3.0.1"
|
4
4
|
s.summary = %{Object-hash mapping library for Redis.}
|
5
5
|
s.description = %Q{Ohm is a library that allows to store an object in Redis, a persistent key-value database. It has very good performance.}
|
6
6
|
s.authors = ["Michel Martens", "Damian Janowski", "Cyril David"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-04-
|
13
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: redic
|