Slide 1

Slide 1 text

PStore.rb 13-05-08

Slide 2

Slide 2 text

# PStore implements a file # based persistence mechanism # based on a Hash. 13-05-08

Slide 3

Slide 3 text

Reading 13-05-08

Slide 4

Slide 4 text

Usage 13-05-08

Slide 5

Slide 5 text

wiki = PStore.new("wiki_pages.pstore") # do all of this or none of it wiki.transaction do # store page... wiki[home_page.page_name] = home_page # ensure that an index has been created... wiki[:wiki_index] ||= Array.new # update wiki index... wiki[:wiki_index].push(*page.references) end # commit changes 13-05-08

Slide 6

Slide 6 text

the gostak distims the doshes - C K Ogden & I A Richards, 1923 13-05-08

Slide 7

Slide 7 text

Correctness 13-05-08

Slide 8

Slide 8 text

def transaction(read_only = false) # :yields: pstore value = nil begin @lock.lock rescue ThreadError raise PStore::Error, "nested transaction" end begin @rdonly = read_only @abort = false file = open_and_lock_file(@filename, read_only) if file begin @table, checksum, original_data_size = load_data(file, read_only) catch(:pstore_abort_transaction) do value = yield(self) end if !@abort && !read_only save_data(checksum, original_data_size, file) end ensure file.close if !file.closed? end else # This can only occur if read_only == true. @table = {} catch(:pstore_abort_transaction) do value = yield(self) end end ensure @lock.unlock end value end 13-05-08

Slide 9

Slide 9 text

Seven Types of Ambiguity - William Empson, 1930 13-05-08

Slide 10

Slide 10 text

Efficiency 13-05-08

Slide 11

Slide 11 text

def save_data_with_atomic_file_rename_strategy(data, file) temp_filename = "#{@filename}.tmp.#{Process.pid}.#{rand 1000000}" temp_file = File.new(temp_filename, WR_ACCESS) begin temp_file.flock(File::LOCK_EX) temp_file.write(data) temp_file.flush File.rename(temp_filename, @filename) rescue File.unlink(temp_file) rescue nil raise ensure temp_file.close end end 13-05-08

Slide 12

Slide 12 text

• Referential • Aesthetic • Emotive • Conative • Phatic • Metalingual - Roman Jacobson, 1960 13-05-08

Slide 13

Slide 13 text

Extend 13-05-08

Slide 14

Slide 14 text

YAML::Store 13-05-08

Slide 15

Slide 15 text

Structure, Sign & Play - Jacques Derrida, 1966 13-05-08

Slide 16

Slide 16 text

History 13-05-08

Slide 17

Slide 17 text

2012-11-11 glass fix not to replace ThreadError raised in #transaction block with PStore::Error. 2011-12-20 nahi Cosmetic changes of lib/pstore.rb. Patch by Masaki Matsushita. See #5248. 2011-12-20 nahi content update perf optimization. Patch by Masaki Matsushita. 2011-11-05 ktsj remove unused block arguments to avoid creating Proc objects. 2011-09-13 nobu suppress warnings with -v. 2011-09-13 nobu always open in binary mode even if default encodings are set. 2011-03-13 sorah Fix don't raise "nested transaction" when thread_safe is true. ! ! ! Patch by Masaki Matsushita (Glass_saga). [ruby-dev:43337] 2011-03-07 sorah Delete variable @transaction and fix #4474. Patch by Masaki Matsushita (Glass_saga). 2010-02-15 akr initialize: initialize @thread_safe. 2009-06-13 nobu on_windows: fixed typo. 2009-03-06 nobu removed trailing spaces. 2008-07-10 nobu transaction: return the result from the block. 2008-06-04 matz massive spelling correction patch from Evan Farrar 2008-04-11 matz YAML::load: modified to support empty database. 2008-04-10 matz dump, load: allow subclass overriding. 2008-04-10 matz replaced by Hongli Lai's faster version. 2006-09-08 nobu open all in binary mode, and get rid of the quirk of msvcrt. 2006-02-05 ocean should return default value if name is not found. should raise PStore::Error if not in transaction. 2005-11-01 matz [no mention] 2005-10-27 matz [no mention] 2005-03-04 matz transaction: Use the empty content when a file is not found. 2004-10-06 matz [no mention] 2004-10-05 matz [no mention] 2004-06-01 nobu PStore#transaction: get rid of opening in write mode when read only transaction 2004-05-27 matz transaction: allow overriding dump and load 2004-03-07 eban commit_new: use FileUtils.copy_stream for Cygwin 2004-02-17 matz [no mention] 2003-01-07 matz [no mention] 2002-11-14 matz [no mention] 2002-07-11 matz [no mention] 2002-06-24 matz [no mention] 2001-12-01 knu Reflect the update of the MD5 module which is now Digest::MD5. 2001-11-19 matz [no mention] 2001-10-03 matz [no mention] 2001-07-31 matz [no mention] 2001-05-06 matz [no mention] 2000-10-11 matz [no mention] 2000-09-19 matz [no mention] 2000-06-13 matz pstore abort handle 2000-03-06 matz [no mention] 1999-11-19 matz [no mention] 1999-11-25 matz [no mention] 1999-11-17 matz [no mention] 1999-01-20 matz [no mention] 1998-01-16 matz Initial revision 13-05-08

Slide 18

Slide 18 text

Qu'est-ce qu'un auteur? - Michel Foucault, 1967 13-05-08