def value_to_doc(key, value, options)
case value
when Hash
value.merge('_id' => key,
@type_field => 'Hash',
@expires_field => expires_at(options) || nil)
when Float, Fixnum
{ '_id' => key,
@type_field => 'Number',
@value_field => value,
@expires_field => expires_at(options) || nil }
when String
intvalue = value.to_i
{ '_id' => key,
@type_field => 'String',
@value_field => intvalue.to_s == value ? intvalue : to_binary(value),
@expires_field => expires_at(options) || nil }
else
raise ArgumentError, "Invalid value type: #{value.class}"
end
end