ankane / blazer

Business intelligence made simple
MIT License
4.56k stars 474 forks source link

Not able to use cache feature #343

Closed babarajay closed 3 years ago

babarajay commented 3 years ago

Hello there,

I'm trying to use caching for my queries but everytime it executed rather getting results from the cache.

I also set the configs on the blazer.yml file for the cache. Here is the code spinet:

cache:
  mode: all
  expires_in: 60 # min

I've overridden the queries_controller and tried to add rails logger just to check the query and it's result and it never execute the below code:

elsif @run_id
         @timestamp = blazer_params[:timestamp].to_i
         @result = @data_source.run_results(@run_id)
         @success = !@result.nil?
          if @success
            @data_source.delete_results(@run_id)
            @columns = @result.columns
            @rows = @result.rows
            @error = @result.error
            @just_cached = !@result.error && @result.cached_at.present?
            @cached_at = nil
            params[:data_source] = nil
            render_run

I'm not sure what I'm missing here; Can anyone help me with this issue please?

Thank you!

ankane commented 3 years ago

Hey @babarajay, I'd check that caching is enabled in your application.

babarajay commented 3 years ago

@ankane thank for your reply.

Yes, caching is already enabled in my application but still facing this issue.

ankane commented 3 years ago

What's the output of cache logging?

babarajay commented 3 years ago

@ankane , actually, I'm trying to override the queries_controller and and passing arguments (params) in such a way that execute the below code snippet. That will bring the results from the cache.

elsif @run_id
         @timestamp = blazer_params[:timestamp].to_i
         @result = @data_source.run_results(@run_id)
         @success = !@result.nil?
          if @success
            @data_source.delete_results(@run_id)
            @columns = @result.columns
            @rows = @result.rows
            @error = @result.error
            @just_cached = !@result.error && @result.cached_at.present?
            @cached_at = nil
            params[:data_source] = nil
            render_run

The above code never executed though I'm passing params in the required fashion.

ankane commented 3 years ago

Unfortunately, I don't really follow what you're trying to do, but check out the Contributing Guide for where to get help.