Top / Programming / Ruby / Ruby ソスfソス[ソス^ソスxソス[ソスXソスソスソスCソスuソスソスソスソス / Madeleine

Madeleine

Madeleineソスヘ、ソスIソスuソスWソスFソスNソスgソスiソスソスソスソスソス@ソス\ソスナゑソスソスB

ソスIソスuソスWソスFソスNソスgソスフスソスiソスbソスvソスVソスソスソスbソスgソスソスソスニるこソスニゑソスソスナゑソスソスワゑソスソスB

ソス_ソスEソスソスソスソスソス[ソスh

ソスCソスソスソスXソスgソス[ソスソス

gem ソスソスソス_ソスEソスソスソスソスソス[ソスhソスソスソスソスソスニゑソス(RubyGemsソスソスソスKソスvソスナゑソス)

# gem install madeleine-0.7.1.gem

tar.gz ソスソスソス_ソスEソスソスソスソスソス[ソスhソスソスソスソスソスニゑソス

$ ruby install.rb config
$ ruby install.rb setup
# ruby install.rb install

ソスgソスpソスソスソス@

Madeleineソスソスソスソスソス[ソスhソスソスソスソス

require 'madeleine'

ソスIソスuソスWソスFソスNソスgソスフ読み搾ソスソスソス

SnapshotMadeleine.new()ソスナ、ソスCソスソスソスXソス^ソスソスソスXソス生撰ソスソスソスソスワゑソスソスB

ソスナ擾ソスソスフ茨ソスソスソスソスヘ、ソスIソスuソスWソスFソスNソスgソスソスロ托ソスソスソスソスソスfソスBソスソスソスNソスgソスソスソスソスソスナゑソスソスBソスfソスBソスソスソスNソスgソスソスソスソスソスネゑソスソスソスホ作成ソスソスソスソスワゑソスソスB

2ソスヤ目の茨ソスソスソスソスヘ、ソス}ソス[ソスVソスソスソスソスソスノ使ソスpソスソスソスソスNソスソスソスXソスナゑソスソスBソスwソス閧オソスネゑソスソス鼾ソスソス Marshal ソスノなゑソスワゑソスソスB

ソスuソスソスソスbソスNソスヘ、ソスIソスuソスWソスFソスNソスgソスソスソス成ソスソスソス髀茨ソスソスソスナゑソスソスBソスiソスソスソスソスソスソスソスソスIソスuソスWソスFソスNソスgソスソスソス成ソスソスソスワゑソスソスB

madeleine = SnapshotMadeleine.new("data_dir") do
  Array.new
end

ソスuソスソスソスbソスNソスフ擾ソスソスソスソスナオソスuソスWソスFソスNソスgソスソスソス成ソスソスソスソスソスソスAソスfソスBソスソスソスNソスgソスソスソスノゑソスソスソスRソス}ソスソスソスhソスソスソスOソスソスソスソスソスソスソスソスソスsソスソスソストゑソスソスソスソスAソスIソスuソスWソスFソスNソスgソスフ擾ソスヤを復鯉ソスソスソスソスワゑソスソスB

ソスIソスuソスWソスFソスNソスgソスフ更ソスV

ソスIソスuソスWソスFソスNソスgソスノは、ソスRソス}ソスソスソスhソスIソスuソスWソスFソスNソスgソスソスハゑソスソストアソスNソスZソスXソスソスソスワゑソスソスB ソスRソス}ソスソスソスhソスIソスuソスWソスFソスNソスgソスソス execute(system) ソスソスソス\ソスbソスhソスソスソスソスソスソスソスソスソスソスソスIソスuソスWソスFソスNソスgソスナゑソスソスB

require 'madeleine'
# ソスfソス[ソス^ソスソスヌ会ソスソスソスソスソスRソス}ソスソスソスh
class PushCommand
  def initialize(data)
    @data = data
  end
  def execute(system)
    system.push(@data)
  end
end
# ソスlソスソスソス謫セソスソスソスソスRソス}ソスソスソスh
class QueryCommand
  def initialize(data)
    @data = data
  end
  def execute(system)
    system[@data]
  end
end
madeleine = SnapshotMadeleine.new("data_dir") do
  Array.new
end
madeleine.execute_command(PushCommand.new('hoge'))
puts madeleine.execute_command(QueryCommand.new(0))

ソスRソス}ソスソスソスhソスIソスuソスWソスFソスNソスgソスノは、Madeleine::Automatic::Command ソスニゑソスソスソスソスト用ソスIソスネクソスソスソスXソスソスソスpソスモゑソスソスソストゑソスソスワゑソスソスB(ソスgソスソスソスソスH)

ソスソスソスソスフ概ソスv

ソスIソスuソスWソスFソスNソスgソスソスロ托ソスソスソスソスソスfソスBソスソスソスNソスgソスソスソスノは、ソスRソス}ソスソスソスhソスソスソスソスソスsソスソスソスソスニコソス}ソスソスソスhソスソスソスOソスフフソス@ソスCソスソスソスソスソス成ソスソスソスソスワゑソスソスB

$ ls
000000000000000000001.command_log
000000000000000000002.command_log
000000000000000000003.command_log

ソスソスソスフソスソスOソスtソス@ソスCソスソスソスフ難ソスソスeソスヘ、ソスRソス}ソスソスソスhソスIソスuソスWソスFソスNソスgソスソスソス}ソス[ソスVソスソスソスソスソスソスソスソスソスfソス[ソス^ソスナゑソスソスB

ソスRソスソスソスXソスgソスソスソスNソス^ソスナは、ソスソスソスフマソス[ソスVソスソスソスソスソスソスソスソスソスRソス}ソスソスソスhソスIソスuソスWソスFソスNソスgソス復鯉ソスソスソスソスAソスソスソスsソスソスソス驍アソスニで、ソスIソスuソスWソスFソスNソスgソスフ擾ソスヤを復鯉ソスソスソスソスワゑソスソスB

ソスヨ連ソスyソス[ソスW

ソスXソスVソスソスソスソス