lib/picky/backends/sqlite/basic.rb in picky-4.17.1 vs lib/picky/backends/sqlite/basic.rb in picky-4.18.0
- old
+ new
@@ -13,12 +13,10 @@
def initialize cache_path, options = {}
@cache_path = "#{cache_path}.sqlite3"
@empty = options[:empty]
@initial = options[:initial]
@realtime = options[:realtime]
-
- lazily_initialize_client
# Note: If on OSX, too many files get opened during
# the specs -> ulimit -n 3000
#
# rescue SQLite3::CantOpenException => e
@@ -44,13 +42,14 @@
def clear
db.execute 'delete from key_value'
end
- # TODO Replace with db method?
+ # Lazily creates SQLite client.
+ # Note: Perhaps it would be advisable to create only one, when initialising.
#
- def lazily_initialize_client
+ def db
@db ||= (create_directory cache_path; SQLite3::Database.new cache_path)
end
def dump_sqlite internal
reset
@@ -65,16 +64,10 @@
end
end
end
def reset
- # TODO Still necessary?
- #
- create_directory cache_path
- lazily_initialize_client
-
truncate_db
-
self
end
# Drops the table and creates it anew.
#