Class: Dalli::Protocol::StringMarshaller
- Inherits:
-
Object
- Object
- Dalli::Protocol::StringMarshaller
- Defined in:
- lib/dalli/protocol/string_marshaller.rb
Overview
Dalli::Protocol::StringMarshaller is a pass-through marshaller for use with the :raw client option. It bypasses serialization and compression entirely, expecting values to already be strings (e.g., pre-serialized by Rails’ ActiveSupport::Cache). It still enforces the maximum value size limit.
Constant Summary collapse
- DEFAULTS =
{ # max size of value in bytes (default is 1 MB, can be overriden with "memcached -I <size>") value_max_bytes: 1024 * 1024 }.freeze
Instance Attribute Summary collapse
-
#value_max_bytes ⇒ Object
readonly
Returns the value of attribute value_max_bytes.
Instance Method Summary collapse
- #compress_by_default? ⇒ Boolean
- #compression_min_size ⇒ Object
- #compressor ⇒ Object
-
#initialize(client_options) ⇒ StringMarshaller
constructor
A new instance of StringMarshaller.
- #retrieve(value, _flags) ⇒ Object
-
#serializer ⇒ Object
Interface compatibility methods - these return nil since StringMarshaller bypasses serialization and compression entirely.
- #store(key, value, _options = nil) ⇒ Object
Constructor Details
#initialize(client_options) ⇒ StringMarshaller
19 20 21 22 23 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 19 def initialize() @value_max_bytes = .fetch(:value_max_bytes) do DEFAULTS.fetch(:value_max_bytes) end.to_i end |
Instance Attribute Details
#value_max_bytes ⇒ Object (readonly)
Returns the value of attribute value_max_bytes.
17 18 19 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 17 def value_max_bytes @value_max_bytes end |
Instance Method Details
#compress_by_default? ⇒ Boolean
51 52 53 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 51 def compress_by_default? false end |
#compression_min_size ⇒ Object
47 48 49 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 47 def compression_min_size nil end |
#compressor ⇒ Object
43 44 45 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 43 def compressor nil end |
#retrieve(value, _flags) ⇒ Object
32 33 34 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 32 def retrieve(value, _flags) value end |
#serializer ⇒ Object
Interface compatibility methods - these return nil since StringMarshaller bypasses serialization and compression entirely.
39 40 41 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 39 def serializer nil end |
#store(key, value, _options = nil) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/dalli/protocol/string_marshaller.rb', line 25 def store(key, value, = nil) raise MarshalError, "Dalli in :raw mode only supports strings, got: #{value.class}" unless value.is_a?(String) error_if_over_max_value_bytes(key, value) [value, 0] end |