-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- cache_supported_queries => Readyset::Query.cache_all_supported! - drop_all_caches => Readyset::Query.drop_all_caches! - all_caches => Readyset::Query.all_cached
- Loading branch information
1 parent
30dc3c8
commit 4708df2
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# lib/tasks/readyset.rake | ||
|
||
namespace :readyset do | ||
desc 'Creates caches for all of the supported queries on ReadySet' | ||
task cache_supported_queries: :environment do | ||
Readyset::Query.cache_all_supported! | ||
end | ||
|
||
desc 'Drops all the caches on ReadySet' | ||
task drop_all_caches: :environment do | ||
Readyset::Query.drop_all_caches! | ||
end | ||
|
||
desc 'Prints a list of all the cached queries on ReadySet' | ||
task all_caches: :environment do | ||
Readyset::Query.all_cached.each do |query| | ||
puts query.inspect | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# spec/tasks/readyset_tasks_spec.rb | ||
|
||
require 'rails_helper' | ||
require 'rake' | ||
|
||
RSpec.describe 'ReadySet tasks', type: :task do | ||
before :all do | ||
Rake.application.rake_require('tasks/readyset') | ||
Rake::Task.define_task(:environment) | ||
end | ||
|
||
describe 'readyset:cache_supported_queries' do | ||
it 'creates caches for all supported queries' do | ||
# Setup | ||
allow(Readyset::Query).to receive(:cache_all_supported!) | ||
|
||
# Exercise | ||
Rake::Task['readyset:cache_supported_queries'].execute | ||
|
||
# Verify | ||
expect(Readyset::Query).to have_received(:cache_all_supported!) | ||
end | ||
end | ||
describe 'readyset:drop_all_caches' do | ||
it 'drops all caches' do | ||
# Setup | ||
allow(Readyset::Query).to receive(:drop_all_caches!) | ||
|
||
# Exercise | ||
Rake::Task['readyset:drop_all_caches'].execute | ||
|
||
# Verify | ||
expect(Readyset::Query).to have_received(:drop_all_caches!) | ||
end | ||
end | ||
|
||
describe 'readyset:all_caches' do | ||
it 'prints all cached queries' do | ||
# Setup | ||
allow(Readyset::Query).to receive(:all_cached).and_return([double, double]) | ||
|
||
# Exercise | ||
Rake::Task['readyset:all_caches'].execute | ||
|
||
# Verify | ||
expect(Readyset::Query).to have_received(:all_cached) | ||
end | ||
end | ||
end |