lib/suo/client/base.rb in suo-0.1.0 vs lib/suo/client/base.rb in suo-0.1.1
- old
+ new
@@ -80,17 +80,18 @@
end
private
def serialize_locks(locks)
- locks.map { |time, token| [time.to_f, token].join(":") }.join(",")
+ MessagePack.pack(locks.map { |time, token| [time.to_f, token] })
end
- def deserialize_locks(str)
- str.split(",").map do |s|
- time, token = s.split(":", 2)
- [Time.at(time.to_f), token]
+ def deserialize_locks(val)
+ MessagePack.unpack(val).map do |time, token|
+ [Time.at(time), token]
end
+ rescue EOFError => _
+ []
end
def clear_expired_locks(locks, options)
expired = Time.now - options[:stale_lock_expiration]
locks.reject { |time, _| time < expired }