class Dalli::Protocol::Binary::RequestFormatter
Class that encapsulates logic for formatting binary protocol requests to memcached.
Constants
- BODY_FORMATS
- FORMAT
- INCR_DECR
- KEY_AND_VALUE
- KEY_ONLY
- NO_BODY
- OPCODES
- REQUEST
- REQ_HEADER_FORMAT
- TTL_AND_KEY
- TTL_ONLY
Public Class Methods
as_8byte_uint(val)
click to toggle source
# File lib/dalli/protocol/binary/request_formatter.rb, line 110 def self.as_8byte_uint(val) [val >> 32, 0xFFFFFFFF & val] end
decr_incr_request(opkey:, key: nil, count: nil, initial: nil, expiry: nil)
click to toggle source
rubocop:enable Metrics/ParameterLists
# File lib/dalli/protocol/binary/request_formatter.rb, line 101 def self.decr_incr_request(opkey:, key: nil, count: nil, initial: nil, expiry: nil) extra_len = 20 (h, l) = as_8byte_uint(count) (dh, dl) = as_8byte_uint(initial) header = [REQUEST, OPCODES[opkey], key.bytesize, extra_len, 0, 0, key.bytesize + extra_len, 0, 0] body = [h, l, dh, dl, expiry, key] (header + body).pack(FORMAT[opkey]) end
standard_request(opkey:, key: nil, value: nil, opaque: 0, cas: 0, bitflags: nil, ttl: nil)
click to toggle source
rubocop:disable Metrics/ParameterLists
# File lib/dalli/protocol/binary/request_formatter.rb, line 91 def self.standard_request(opkey:, key: nil, value: nil, opaque: 0, cas: 0, bitflags: nil, ttl: nil) extra_len = (bitflags.nil? ? 0 : 4) + (ttl.nil? ? 0 : 4) key_len = key.nil? ? 0 : key.bytesize value_len = value.nil? ? 0 : value.bytesize header = [REQUEST, OPCODES[opkey], key_len, extra_len, 0, 0, extra_len + key_len + value_len, opaque, cas] body = [bitflags, ttl, key, value].compact (header + body).pack(FORMAT[opkey]) end