lib/memcached/memcached.rb
# EXPERIMENTAL
#
# Sets a key/value pair that is (potentially) bigger than 1MB (i.e. the memcached limit for bucket sizes).
#
# Accepts optional <tt>timeout</tt> and <tt>marshal</tt> arguments like <tt>set</tt>.
#
# The value is split into chunks (each smaller than or equal in size to the <tt>chunk_split_size</tt> option)
# and inserted into separate buckets. The keys are of the form: #{key}_0, #{key}_1, #{key}_2.
# The bucket referred to by the given <tt>key</tt> contains a chunk "header" with a #chunks property that equals
# the number of chunks.
#
# Note that values that fit within a single chunk _are_ still "split" - the chunk header (and the single chunk)
# is still set.
#
# WARNING: This method is non-atomic by nature, since we are really performing multiple <tt>set</tt>s serially.
EXPERIMENTAL
Sets a key/value pair that is (potentially) bigger than 1MB .

Accepts optional timeout and marshal arguments like set.

The value is split into chunks (each smaller than or equal in size to the chunk_split_size option)
and inserted into separate buckets.

Note that values that fit within a single chunk _are_ still "split" - the chunk header (and the single chunk)
is still set.

This method is non-atomic by nature, since we are really performing multiple sets serially.
EXPERIMENTAL Sets a key / value pair that is ( potentially ) bigger than 1MB . Accepts optional timeout and marshal arguments like set . The value is split into chunks ( each smaller than or equal in size to the chunk_split_size option ) and inserted into separate buckets . Note that values that fit within a single chunk _are_ still " split " - the chunk header ( and the single chunk ) is still set . This method is non - atomic by nature since we are really performing multiple sets serially .
def big_set(key, value, timeout=0, marshal=true)
    value = marshal ? Marshal.dump(value) : value.to_s
    chunk_size = options[:chunk_split_size]
    chunks = (value.size/chunk_size.to_f).ceil
    set(key, OpenStruct.new(:chunks => chunks), timeout, true)
    chunks.times do |chunk_num|
      set("#{key}_#{chunk_num}", value[chunk_num * chunk_size, chunk_size], timeout, false)
    end
  end
def big_set ( key , value , timeout = 0 , marshal = true ) value = marshal ? Marshal . dump ( value ) : value . to_s chunk_size = options [ :chunk_split_size ] chunks = ( value . size / chunk_size . to_f ) . ceil set ( key , OpenStruct . new ( :chunks => chunks ) , timeout , true ) chunks . times do | chunk_num | set ( "#{key}_#{chunk_num}" , value [ chunk_num * chunk_size , chunk_size ] , timeout , false ) end end
EXPERIMENTAL
Sets a key/value pair that is (potentially) bigger than 1MB (i.e.
EXPERIMENTAL Sets a key / value pair that is ( potentially ) bigger than 1MB ( i . e .
# Set the number of chunks (in a faux "header") in the bucket for the actual key.
key
value
timeout
marshal