### Home Classes Methods

### In Files

- lib/memcache/base.rb

### Parent

Object

### Methods

- #add
- #append
- #cache_key
- #cas
- #clear
- #decr
- #gets
- #incr
- #prepend
- #replace

### Files

- LICENSE
- README.rdoc

### 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::Base

### Attributes

prefix[RW]

### Public Instance Methods

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

    # File lib/memcache/base.rb, line 30
    def add(key, value, expiry = 0, flags = 0)
      return nil if get(key)
      set(key, value, expiry)
    end

append(key, value) click to toggle source

    # File lib/memcache/base.rb, line 45
    def append(key, value)
      existing = get(key)
      return false if existing.nil?
      set(key, existing + value) && true
    end

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

    # File lib/memcache/base.rb, line 35
    def cas(key, value, cas, expiry = 0, flags = 0)
      # No cas implementation yet, just do a set for now.
      set(key, value, expiry, flags)
    end

clear() click to toggle source

    # File lib/memcache/base.rb, line 5
    def clear
      flush_all
    end

decr(key, amount = 1) click to toggle source

    # File lib/memcache/base.rb, line 26
    def decr(key, amount = 1)
      incr(key, -amount)
    end

gets(keys) click to toggle source

Default implementations based on get and set.

    # File lib/memcache/base.rb, line 11
    def gets(keys)
      get(keys, true)
    end

incr(key, amount = 1) click to toggle source

    # File lib/memcache/base.rb, line 15
    def incr(key, amount = 1)
      value = get(key)
      return unless value
      return unless value =~ /^\d+$/

      value = value.to_i + amount
      value = 0 if value < 0
      set(key, value.to_s)
      value
    end

prepend(key, value) click to toggle source

    # File lib/memcache/base.rb, line 51
    def prepend(key, value)
      existing = get(key)
      return false if existing.nil?
      set(key, value + existing) && true
    end

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

    # File lib/memcache/base.rb, line 40
    def replace(key, value, expiry = 0, flags = 0)
      return nil if get(key).nil?
      set(key, value, expiry)
    end

### Protected Instance Methods

cache_key(key) click to toggle source

    # File lib/memcache/base.rb, line 59
    def cache_key(key)
      raise Memcache::Error, "length zero key not permitted" if key.length == 0
      key = "#{prefix}#{key}"
      raise Memcache::Error, "key too long #{key.inspect}" if key.length > 250
      key
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.