Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introduce a protocol version that has to be bumped every time we chan…

…ge to structure of the data we store in memcached
  • Loading branch information...
commit fc328b51e7834449939a1f7963d7309d0dec7bb1 1 parent e3c609e
@staugaard staugaard authored
View
2  lib/kasket/configuration_mixin.rb
@@ -23,7 +23,7 @@ def kasket_parser
end
def kasket_key_prefix
- @kasket_key_prefix ||= "kasket-#{Kasket::Version::STRING}/#{table_name}/version=#{column_names.join.sum}/"
+ @kasket_key_prefix ||= "kasket-#{Kasket::Version::PROTOCOL}/#{table_name}/version=#{column_names.join.sum}/"
end
def kasket_key_for(attribute_value_pairs)
View
1  lib/kasket/version.rb
@@ -5,5 +5,6 @@ class Version
MINOR = 0
PATCH = 0
STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
+ PROTOCOL = 3
end
end
View
2  test/configuration_mixin_test.rb
@@ -6,7 +6,7 @@ class ConfigurationMixinTest < ActiveSupport::TestCase
context "Generating cache keys" do
should "not choke on empty numeric attributes" do
- expected_cache_key = "kasket-#{Kasket::Version::STRING}/posts/version=4517/blog_id=NULL"
+ expected_cache_key = "kasket-#{Kasket::Version::PROTOCOL}/posts/version=4517/blog_id=NULL"
query_attributes = [ [:blog_id, ''] ]
assert_equal expected_cache_key, Post.kasket_key_for(query_attributes)
View
2  test/parser_test.rb
@@ -172,7 +172,7 @@ class ParserTest < ActiveSupport::TestCase
else
kasket_query = @parser.parse("SELECT * FROM `posts` WHERE (id = 1)")
end
- assert_match(/^kasket-#{Kasket::Version::STRING}\/posts\/version=4517\//, kasket_query[:key])
+ assert_match(/^kasket-#{Kasket::Version::PROTOCOL}\/posts\/version=4517\//, kasket_query[:key])
end
should "include all indexed attributes" do
View
10 test/read_mixin_test.rb
@@ -20,20 +20,20 @@ class ReadMixinTest < ActiveSupport::TestCase
end
should "read results" do
- Kasket.cache.write("kasket-#{Kasket::Version::STRING}/posts/version=4517/id=1", @post_database_result)
+ Kasket.cache.write("kasket-#{Kasket::Version::PROTOCOL}/posts/version=4517/id=1", @post_database_result)
assert_equal @post_records, Post.find_by_sql('SELECT * FROM `posts` WHERE (id = 1)')
end
should "store results in kasket" do
Post.find_by_sql('SELECT * FROM `posts` WHERE (id = 1)')
- assert_equal @post_database_result, Kasket.cache.read("kasket-#{Kasket::Version::STRING}/posts/version=4517/id=1")
+ assert_equal @post_database_result, Kasket.cache.read("kasket-#{Kasket::Version::PROTOCOL}/posts/version=4517/id=1")
end
should "store multiple records in cache" do
Comment.find_by_sql('SELECT * FROM `comments` WHERE (post_id = 1)')
- stored_value = Kasket.cache.read("kasket-#{Kasket::Version::STRING}/comments/version=3476/post_id=1")
- assert_equal(["kasket-#{Kasket::Version::STRING}/comments/version=3476/id=1", "kasket-#{Kasket::Version::STRING}/comments/version=3476/id=2"], stored_value)
+ stored_value = Kasket.cache.read("kasket-#{Kasket::Version::PROTOCOL}/comments/version=3476/post_id=1")
+ assert_equal(["kasket-#{Kasket::Version::PROTOCOL}/comments/version=3476/id=1", "kasket-#{Kasket::Version::PROTOCOL}/comments/version=3476/id=2"], stored_value)
assert_equal(@comment_database_result, stored_value.map {|key| Kasket.cache.read(key)})
Comment.expects(:find_by_sql_without_kasket).never
@@ -43,7 +43,7 @@ class ReadMixinTest < ActiveSupport::TestCase
context "modifying results" do
setup do
- Kasket.cache.write("kasket-#{Kasket::Version::STRING}/posts/version=4517/id=1", @post_database_result)
+ Kasket.cache.write("kasket-#{Kasket::Version::PROTOCOL}/posts/version=4517/id=1", @post_database_result)
@record = Post.find_by_sql('SELECT * FROM `posts` WHERE (id = 1)').first
@record.instance_variable_get(:@attributes)['id'] = 3
end
Please sign in to comment.
Something went wrong with that request. Please try again.