Class: ActiveFedora::Base
- Inherits:
-
Object
- Object
- ActiveFedora::Base
show all
- Defined in:
- lib/sufia/models/active_fedora/redis.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.stream ⇒ Object
9
10
11
12
13
|
# File 'lib/sufia/models/active_fedora/redis.rb', line 9
def self.stream
Nest.new(name, $redis)
rescue
nil
end
|
Instance Method Details
#create_event(action, timestamp) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/sufia/models/active_fedora/redis.rb', line 26
def create_event(action, timestamp)
event_id = $redis.incr("events:latest_id")
$redis.hmset("events:#{event_id}", "action", action, "timestamp", timestamp)
event_id
rescue
nil
end
|
#events(size = -1)) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sufia/models/active_fedora/redis.rb', line 15
def events(size = -1)
stream[:event].lrange(0, size).map do |event_id|
{
action: $redis.hget("events:#{event_id}", "action"),
timestamp: $redis.hget("events:#{event_id}", "timestamp")
}
end
rescue
[]
end
|
#log_event(event_id) ⇒ Object
34
35
36
37
38
|
# File 'lib/sufia/models/active_fedora/redis.rb', line 34
def log_event(event_id)
stream[:event].lpush(event_id)
rescue
nil
end
|
#stream ⇒ Object
3
4
5
6
7
|
# File 'lib/sufia/models/active_fedora/redis.rb', line 3
def stream
Nest.new(self.class.name, $redis)[to_param]
rescue
nil
end
|