Sha256: 3fcdf7bb65617c5b9021be41edf1e4be96abc490016b797402ab8569bbc014b1

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

require 'pstore'

module TwiAuth
  # A simple key value store using PStore, provided by ruby
  class Store
    # Filename for pstore data file
    DATA_FILE = "data.pstore"
    # :nodoc:
    def initialize
      @store = PStore.new("#{PATH}#{DATA_FILE}")
    end

    # put a key with value
    def put(key, value)
      @store.transaction do
        @store[key] = value
      end
    end

    # get the value of the key 
    def get(key)
      @store.transaction do
        @value = @store[key]
      end
      @value
    end

    # delete a key 
    def delete(key)
      @store.transaction do
        @store.delete(key)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twiauth-0.1.0 lib/twiauth/store.rb