Class: StompServer::DBMQueue

### Home Classes Methods

### In Files

- lib/stomp_server/queue/dbm_queue.rb

### Parent

StompServer::Queue

### Methods

- ::new
- #_close_queue
- #_open_queue
- #_readframe
- #_writeframe
- #dbmopen

### Files

- History.txt
- Manifest.txt
- README.txt
- README.txt

### Class/Module Index

Quicksearch

- StompServer
- StompServer::ActiveRecordQueue
- StompServer::Configurator
- StompServer::DBMQueue
- StompServer::FileQueue
- StompServer::MemoryQueue
- StompServer::Protocols
- StompServer::Protocols::Http
- StompServer::Protocols::Stomp
- StompServer::Queue
- StompServer::QueueManager
- StompServer::QueueMonitor
- StompServer::Run
- StompServer::StompAuth
- StompServer::StompFrame
- StompServer::StompFrameRecognizer
- StompServer::StompId
- StompServer::StompUser
- StompServer::TestServer
- StompServer::TopicManager
- Mongrel
- Mongrel::HttpRequest
- ArMessage

No matching classes.

# StompServer::DBMQueue

### Public Class Methods

new(*args) click to toggle source

    # File lib/stomp_server/queue/dbm_queue.rb, line 5
    def initialize *args
      super
      # Please don't use dbm files for storing large frames, it's problematic at best and uses large amounts of memory.
      # sdbm croaks on marshalled data that contains certain characters, so we don't use it at all
      @dbm = false
      if RUBY_PLATFORM =~/linux|bsd/
        types = ['bdb','dbm','gdbm']
      else
        types = ['bdb','gdbm']
      end
      types.each do |dbtype|
        begin
          require dbtype
          @dbm = dbtype
          puts "#{@dbm} loaded"
          break
        rescue LoadError => e
        end
      end
      raise "No DBM library found. Tried bdb,dbm,gdbm" unless @dbm
      @db = Hash.new
      @queues.keys.each {|q| _open_queue(q)}
    end

### Public Instance Methods

_close_queue(dest) click to toggle source

    # File lib/stomp_server/queue/dbm_queue.rb, line 49
    def _close_queue(dest)
      @db[dest][:dbh].close
      dbname = @db[dest][:dbname]
      File.delete(dbname) if File.exists?(dbname)
      File.delete("#{dbname}.db") if File.exists?("#{dbname}.db")
      File.delete("#{dbname}.pag") if File.exists?("#{dbname}.pag")
      File.delete("#{dbname}.dir") if File.exists?("#{dbname}.dir")
    end

_open_queue(dest) click to toggle source

    # File lib/stomp_server/queue/dbm_queue.rb, line 40
    def _open_queue(dest)
      queue_name = dest.gsub('/', '_')
      dbname = @directory + '/' + queue_name
      @db[dest] = Hash.new
      @db[dest][:dbh] = dbmopen(dbname)
      @db[dest][:dbname] = dbname
    end

_readframe(dest,msgid) click to toggle source

    # File lib/stomp_server/queue/dbm_queue.rb, line 62
    def _readframe(dest,msgid)
      frame_image = @db[dest][:dbh][msgid]
      Marshal::load(frame_image)
    end

_writeframe(dest,frame,msgid) click to toggle source

    # File lib/stomp_server/queue/dbm_queue.rb, line 58
    def _writeframe(dest,frame,msgid)
      @db[dest][:dbh][msgid] = Marshal::dump(frame)
    end

dbmopen(dbname) click to toggle source

    # File lib/stomp_server/queue/dbm_queue.rb, line 29
    def dbmopen(dbname)
      if @dbm == 'bdb'
        BDB::Hash.new(dbname, nil, "a")
      elsif @dbm == 'dbm'
        DBM.open(dbname)
      elsif @dbm == 'gdbm'
        GDBM.open(dbname)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.