Class: Blazer::ResultCache

Inherits:
Object
  • Object
show all
Defined in:
lib/blazer/result_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(data_source) ⇒ ResultCache

Returns a new instance of ResultCache.



3
4
5
# File 'lib/blazer/result_cache.rb', line 3

def initialize(data_source)
  @data_source = data_source
end

Instance Method Details

#delete_run(run_id) ⇒ Object



15
16
17
# File 'lib/blazer/result_cache.rb', line 15

def delete_run(run_id)
  delete(run_cache_key(run_id))
end

#delete_statement(statement) ⇒ Object



27
28
29
# File 'lib/blazer/result_cache.rb', line 27

def delete_statement(statement)
  delete(statement_cache_key(statement)) if caching?
end

#read_run(run_id) ⇒ Object



11
12
13
# File 'lib/blazer/result_cache.rb', line 11

def read_run(run_id)
  read(run_cache_key(run_id))
end

#read_statement(statement) ⇒ Object



23
24
25
# File 'lib/blazer/result_cache.rb', line 23

def read_statement(statement)
  read(statement_cache_key(statement)) if caching?
end

#write_run(run_id, result) ⇒ Object



7
8
9
# File 'lib/blazer/result_cache.rb', line 7

def write_run(run_id, result)
  write(run_cache_key(run_id), result, expires_in: 30.seconds)
end

#write_statement(statement, result, expires_in:) ⇒ Object



19
20
21
# File 'lib/blazer/result_cache.rb', line 19

def write_statement(statement, result, expires_in:)
  write(statement_cache_key(statement), result, expires_in: expires_in) if caching?
end