### Home Classes Methods

### In Files

- lib/memcache/segmented.rb

### Methods

- #add
- #cas
- #delete
- #get
- #replace
- #set

### Class/Module Index

Quicksearch

- Memcache
- Memcache::Base
- Memcache::ClientError
- Memcache::ConnectionError
- Memcache::Error
- Memcache::LocalServer
- Memcache::Migration
- Memcache::NullServer
- Memcache::PGServer
- Memcache::Pool
- Memcache::Segmented
- Memcache::SegmentedNativeServer
- Memcache::SegmentedServer
- Memcache::Server
- Memcache::ServerError
- Object
- PGconn

No matching classes.

# Memcache::Segmented

### Constants

MAX_SIZE
PARTIAL_VALUE

### Public Instance Methods

add(key, value, expiry = 0, flags = 0) click to toggle source

    # File lib/memcache/segmented.rb, line 56
    def add(key, value, expiry = 0, flags = 0)
      hash, flags = store_segments(key, value, expiry, flags)
      super(key, hash, expiry, flags) && value
    end

cas(key, value, cas, expiry = 0, flags = 0) click to toggle source

    # File lib/memcache/segmented.rb, line 49
    def cas(key, value, cas, expiry = 0, flags = 0)
      delete(key) do
        hash, flags = store_segments(key, value, expiry, flags)
        super(key, hash, cas, expiry, flags) && value
      end
    end

delete(key) click to toggle source

    # File lib/memcache/segmented.rb, line 68
    def delete(key)
      value  = super_get(key)
      result = block_given? ? yield : super
      if result and segmented?(value)
        segment_keys(value).each {|k| super(k)}
      end
      result
    end

get(keys, cas = nil) click to toggle source

    # File lib/memcache/segmented.rb, line 8
    def get(keys, cas = nil)
      return get([keys], cas)[keys.to_s] unless keys.kind_of?(Array)
      return {} if keys.empty?

      results = super(keys, cas)
      keys = {}
      keys_to_fetch = []
      results.each do |key, value|
        next unless segmented?(value)
        keys[key] = segment_keys(value)
        keys_to_fetch.concat keys[key]
      end

      parts = super(keys_to_fetch)
      keys.each do |key, hashes|
        value = ''
        hashes.each do |hash_key|
          if part = parts[hash_key]
            value << part
          else
            value = nil
            break
          end
        end

        if value
          value.memcache_cas   = results[key].memcache_cas
          value.memcache_flags = results[key].memcache_flags ^ PARTIAL_VALUE
        end
        results[key] = value
      end
      results
    end

replace(key, value, expiry = 0, flags = 0) click to toggle source

    # File lib/memcache/segmented.rb, line 61
    def replace(key, value, expiry = 0, flags = 0)
      delete(key) do
        hash, flags = store_segments(key, value, expiry, flags)
        super(key, hash, expiry, flags) && value
      end
    end

set(key, value, expiry = 0, flags = 0) click to toggle source

    # File lib/memcache/segmented.rb, line 42
    def set(key, value, expiry = 0, flags = 0)
      delete(key) do
        hash, flags = store_segments(key, value, expiry, flags)
        super(key, hash, expiry, flags) && value
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.