Sha256: 03c40f34e353074d33c382cac67f4fe412ee81e008afb26e7fced66c2f0dfff6

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

require 'cassandra'

module CurlyMustache
  module Adapters
    class Cassandra < Abstract
      
      def initialize(options)
        @client = ::Cassandra.new(options[:keyspace], options[:servers])
        @column_family = options[:column_family]
      end
      
      def column_family
        @column_family || model_class.name.pluralize.to_sym
      end
      
      def put(key, value)
        @client.insert(column_family, key, value)
      end
      
      def get(key)
        result = @client.get(column_family, key)
        result.empty? ? nil : result
      end
      
      def delete(key)
        @client.remove(column_family, key)
      end
      
      def flush_db
        @client.clear_keyspace!
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curly_mustache-0.1.0 lib/curly_mustache/adapters/cassandra.rb