Class: Webmachine::Trace::PStoreTraceStore

Inherits:
Object
  • Object
show all
Defined in:
lib/webmachine/trace/pstore_trace_store.rb

Overview

Implements a trace storage using PStore from Ruby's standard library. To use this trace store, specify the :pstore engine and a path where it can store traces:

Examples:

Webmachine::Trace.trace_store = :pstore, "/tmp/webmachine.trace"

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PStoreTraceStore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PStoreTraceStore

Parameters:

  • path (String)

    where to store traces in a PStore


13
14
15
# File 'lib/webmachine/trace/pstore_trace_store.rb', line 13

def initialize(path)
  @pstore = PStore.new(path)
end

Instance Method Details

#[]=(key, trace) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Records a trace in the store


34
35
36
# File 'lib/webmachine/trace/pstore_trace_store.rb', line 34

def []=(key, trace)
  @pstore.transaction { @pstore[key] = trace }
end

#fetch(key) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fetches a trace from the store

Parameters:

  • key (String)

    the trace to fetch

Returns:

  • (Array)

    a raw trace


28
29
30
# File 'lib/webmachine/trace/pstore_trace_store.rb', line 28

def fetch(key)
  @pstore.transaction(true) { @pstore[key] }
end

#keysArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Lists the recorded traces

Returns:

  • (Array)

    a list of recorded traces


20
21
22
# File 'lib/webmachine/trace/pstore_trace_store.rb', line 20

def keys
  @pstore.transaction(true) { @pstore.roots }
end