Class: Twing::Cursor
- Inherits:
-
Object
- Object
- Twing::Cursor
- Defined in:
- lib/twing/cursor.rb
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(key, use_redis = true) ⇒ Cursor
constructor
A new instance of Cursor.
- #set(value) ⇒ Object
Constructor Details
#initialize(key, use_redis = true) ⇒ Cursor
Returns a new instance of Cursor.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/twing/cursor.rb', line 3 def initialize(key, use_redis = true) @key = key @use_redis = use_redis if @use_redis @redis = Redis.current else @cursor = nil end end |
Instance Method Details
#get ⇒ Object
14 15 16 17 |
# File 'lib/twing/cursor.rb', line 14 def get return @redis.get(@key) if @use_redis @cursor end |
#set(value) ⇒ Object
19 20 21 22 |
# File 'lib/twing/cursor.rb', line 19 def set(value) return @redis.set(@key, value) if @use_redis @cursor = value end |