Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
PStore.new
[unchecked out K = untyped, unchecked out V = untyped] (::path file, ?::boolish thread_safe) -> ::PStore[K, V]
new(file, thread_safe = false)
lib/pstore.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/pstore.rb, line 372
def initialize(file, thread_safe = false)
dir = File::dirname(file)
unless File::directory? dir
raise PStore::Error, format("directory %s does not exist", dir)
end
if File::exist? file and not File::readable? file
raise PStore::Error, format("file %s not readable", file)
end
@filename = file
@abort = false
@ultra_safe = false
@thread_safe = thread_safe
@lock = Thread::Mutex.new
end
Returns a new PStore object.
Argument file is the path to the file in which objects are to be stored; if the file exists, it should be one that was written by PStore.
Example
path = 't.store' store = PStore.new(path)
A PStore object is reentrant. If argument thread_safe is given as true, the object is also thread-safe (at the cost of a small performance penalty):
Example
store = PStore.new(path, true)