### Home Classes Methods

### In Files

- lib/memcache/local_server.rb

### Parent

Memcache::Base

### Methods

- ::new
- #delete
- #flush_all
- #get
- #name
- #set
- #stats

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

### Public Class Methods

new() click to toggle source

    # File lib/memcache/local_server.rb, line 3
    def initialize
      @data = {}
      @expiry = {}
    end

### Public Instance Methods

delete(key) click to toggle source

    # File lib/memcache/local_server.rb, line 57
    def delete(key)
      @data.delete(cache_key(key)) && true
    end

flush_all(delay = 0) click to toggle source

    # File lib/memcache/local_server.rb, line 19
    def flush_all(delay = 0)
      raise 'flush_all not supported with delay' if delay != 0
      @data.clear
      @expiry.clear
    end

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

    # File lib/memcache/local_server.rb, line 25
    def get(keys, cas = false)
      if keys.kind_of?(Array)
        hash = {}
        keys.each do |key|
          key = key.to_s
          val = get(key)
          hash[key] = val if val
        end
        hash
      else
        key = cache_key(keys)
        if @expiry[key] and Time.now > @expiry[key]
          @data[key]   = nil
          @expiry[key] = nil
        end
        @data[key]
      end
    end

name() click to toggle source

    # File lib/memcache/local_server.rb, line 8
    def name
      "local:#{hash}"
    end

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

    # File lib/memcache/local_server.rb, line 44
    def set(key, value, expiry = 0, flags = 0)
      key = cache_key(key)
      @data[key] = value.to_s
      expiry = Time.at(expiry) if expiry > 60*60*24*30
      if expiry.kind_of?(Time)
        @expiry[key] = expiry
      else
        expiry = expiry.to_i
        @expiry[key] = expiry == 0 ? nil : Time.now + expiry
      end
      value
    end

stats() click to toggle source

    # File lib/memcache/local_server.rb, line 12
    def stats
      { # curr_items may include items that have expired.
        'curr_items'   => @data.size,
        'expiry_count' => @expiry.size,
      }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.