Class: Cassandra::Batch

### Home Classes Methods

### In Files

- lib/cassandra/batch.rb

### Parent

Object

### Methods

- ::new
- #<<
- #each
- #length

### Included Modules

- Enumerable

### Files

- CHANGELOG
- LICENSE
- Makefile

### Class/Module Index

Quicksearch

- Cassandra
- Cassandra::Batch
- Cassandra::ColumnFamily
- Cassandra::Comparable
- Cassandra::Composite
- Cassandra::Consistency
- Cassandra::Constants
- Cassandra::DynamicComposite
- Cassandra::Helpers
- Cassandra::Keyspace
- Cassandra::Long
- Cassandra::Mock
- CassandraThrift
- CassandraThrift::Cassandra
- CassandraThrift::Cassandra::Client
- SimpleUUID
- SimpleUUID::UUID
- Array
- Time

No matching classes.

# Cassandra::Batch

### Public Class Methods

new(cassandra, options) click to toggle source

    # File lib/cassandra/batch.rb, line 5
    def initialize(cassandra, options)
      @queue_size = options.delete(:queue_size) || 0
      @cassandra = cassandra
      @options = options
      @batch_queue = []
    end

### Public Instance Methods

<<(mutation) click to toggle source

Append mutation to the batch queue Flush the batch queue if full

    # File lib/cassandra/batch.rb, line 16
    def <<(mutation)
      @batch_queue << mutation
      if @queue_size > 0 and @batch_queue.length >= @queue_size
        begin
          @cassandra.flush_batch(@options)
        ensure
          @batch_queue = []
        end
      end
    end

each(&block) click to toggle source

Implement each method (required by Enumerable)

    # File lib/cassandra/batch.rb, line 30
    def each(&block)
      @batch_queue.each(&block)
    end

length() click to toggle source

Queue size

    # File lib/cassandra/batch.rb, line 37
    def length
      @batch_queue.length
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.