### Home Classes Methods

### In Files

- lib/termtter/memory_cache.rb

### Parent

DelegateClass(Hash)

### Methods

- ::new
- #adjust
- #flush_all
- #get
- #get_multi
- #set
- #stats
- #try_clone

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandLine
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- Termtter::Event
- Termtter::HTTPpool
- Termtter::Hook
- Termtter::HookCanceled
- Termtter::Hookable
- Termtter::JSONError
- Termtter::MemoryCache
- Termtter::MemoryCache::MemCacheMock
- Termtter::OptParser
- Termtter::Plugin
- Termtter::Plugin::Screen
- Termtter::Plugins
- Termtter::Plugins::Haml
- Termtter::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::Storage
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::UserStreamReceiver
- OAuth
- OAuth::AccessToken
- Array
- Growl
- IRB
- Object
- Readline
- Status
- String
- Symbol
- TermColor
- User

No matching classes.

# Termtter::MemoryCache::MemCacheMock

### Public Class Methods

new(dummy_server) click to toggle source

    # File lib/termtter/memory_cache.rb, line 34
    def initialize(dummy_server)
      super(Hash.new)
      @keys = []
      @limit = 10000
    end

### Public Instance Methods

flush_all(delay = 0) click to toggle source

    # File lib/termtter/memory_cache.rb, line 62
    def flush_all(delay = 0)
      clear
    end

get(key, raw = false) click to toggle source

    # File lib/termtter/memory_cache.rb, line 46
    def get(key, raw = false)
      try_clone self[key]
    end

get_multi(*keys) click to toggle source

    # File lib/termtter/memory_cache.rb, line 50
    def get_multi(*keys)
      results = {}
      keys.each{ |key|
        results[key] = try_clone self[key]
      }
      results
    end

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

    # File lib/termtter/memory_cache.rb, line 40
    def set(key, value, expiry = 0, raw = false)
      self[key] = try_clone value
      adjust(key)
      self
    end

stats() click to toggle source

    # File lib/termtter/memory_cache.rb, line 58
    def stats
      { "total_items"=> length }
    end

### Protected Instance Methods

adjust(key) click to toggle source

    # File lib/termtter/memory_cache.rb, line 72
    def adjust(key)
      return if @keys.include?(key)
      @keys << key
      delete(@keys.shift) while @keys.size > @limit
    end

try_clone(a) click to toggle source

    # File lib/termtter/memory_cache.rb, line 68
    def try_clone(a)
      a.clone rescue a
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.