lib/trifle/stats/driver/postgres.rb in trifle-stats-0.4.1 vs lib/trifle/stats/driver/postgres.rb in trifle-stats-1.0.0

- old
+ new

@@ -42,16 +42,18 @@ query = "INSERT INTO trifle_stats(key, data) VALUES ('#{key}', '#{data.to_json}') ON CONFLICT (key) DO UPDATE SET data = '#{data.to_json}'" # rubocop:disable Metric/LineLength client.exec(query) end - def get(key:) - pkey = key.join(separator) + def get(keys:) + keys.map do |key| + pkey = key.join(separator) - data = _get(key: pkey) - return {} if data.nil? + data = _get(key: pkey) + return {} if data.nil? - self.class.unpack(hash: data) + self.class.unpack(hash: data) + end end def _get(key:) result = client.exec_params( "SELECT * FROM #{table_name} WHERE key = $1 LIMIT 1;", [key]