vendor/bundle/ruby/1.8/gems/Ruby-MemCache-0.0.1/lib/memcache.rb
### Prepare the specified value +val+ for insertion into the cache,
### serializing and compressing as necessary/configured.
Prepare the specified value +val+ for insertion into the cache,
serializing and compressing as necessary/configured.
Prepare the specified value + val + for insertion into the cache serializing and compressing as necessary / configured .
def prep_value( val )
		sval = nil
		flags = 0
		case val
		when String
			sval = val.dup
		when Numeric
			sval = val.to_s
			flags |= F_NUMERIC
		else
			self.debug_msg "Serializing %p" % val
			sval = Marshal::dump( val )
			flags |= F_SERIALIZED
		end
		if @compress && sval.length > @c_threshold
			zipped = Zlib::ZStream::Deflate::deflate( sval )
			if zipped.length < (sval.length * MinCompressionRatio)
				self.debug_msg "Using compressed value (%d/%d)" %
					[ zipped.length, sval.length ]
				sval = zipped
				flags |= F_COMPRESSED
			end
		end
		unless !@urlencode
			sval = URI::escape( sval )
			flags |= F_ESCAPED
		end
		return sval, flags
	end
def prep_value ( val ) sval = nil flags = 0 case val when String sval = val . dup when Numeric sval = val . to_s flags |= F_NUMERIC else self . debug_msg "Serializing %p" % val sval = Marshal :: dump ( val ) flags |= F_SERIALIZED end if @compress && sval . length > @c_threshold zipped = Zlib :: ZStream :: Deflate :: deflate ( sval ) if zipped . length < ( sval . length * MinCompressionRatio ) self . debug_msg "Using compressed value (%d/%d)" % [ zipped . length , sval . length ] sval = zipped flags |= F_COMPRESSED end end unless ! @urlencode sval = URI :: escape ( sval ) flags |= F_ESCAPED end return sval , flags end
Prepare the specified value +val+ for insertion into the cache,
serializing and compressing as necessary/configured.
Prepare the specified value + val + for insertion into the cache serializing and compressing as necessary / configured .
# Serialize if something other than a String, Numeric # Compress if compression is enabled, the value exceeds the # compression threshold, and the compressed value is smaller than # the uncompressed version. # Urlencode unless told not to
val