rails-brotli-cache 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9c5512004d2aecf612e5d79e2b1718466af061f9e4365f2589d767a8d28bf523
         | 
| 4 | 
            +
              data.tar.gz: 89bffbc70d9cd93e8daf4e65731d4023f82703910b0dc333b3fc07775409ae7b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 329a2f361c842187b6c1afc4585dec17638950503908bd9991f83b4243eb8a798903a10a6537650acb6cf229dd1327b79e8bea5467c2abde07f64e926656c08a
         | 
| 7 | 
            +
              data.tar.gz: fbb555285118d28986c453b2a7c7935ce35a8d06d88d581888f54bff82426e2f8b705a21e42d7b2d63ce18ee20e277c3a08b2e11ff9d1701c41377501faa5088
         | 
| @@ -42,13 +42,6 @@ module RailsBrotliCache | |
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| 44 44 | 
             
                def write(name, value, options = nil)
         | 
| 45 | 
            -
                  if value.is_a?(Integer)
         | 
| 46 | 
            -
                    return @core_store.write(
         | 
| 47 | 
            -
                      cache_key(name),
         | 
| 48 | 
            -
                      value
         | 
| 49 | 
            -
                    )
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
             | 
| 52 45 | 
             
                  options = (options || {}).reverse_merge(compress: true)
         | 
| 53 46 | 
             
                  payload = compressed(value, options)
         | 
| 54 47 |  | 
| @@ -126,6 +119,7 @@ module RailsBrotliCache | |
| 126 119 | 
             
                private
         | 
| 127 120 |  | 
| 128 121 | 
             
                def compressed(value, options)
         | 
| 122 | 
            +
                  return value if value.is_a?(Integer)
         | 
| 129 123 | 
             
                  options ||= {}
         | 
| 130 124 | 
             
                  serialized = Marshal.dump(value)
         | 
| 131 125 |  | 
| @@ -171,7 +165,7 @@ module RailsBrotliCache | |
| 171 165 | 
             
                end
         | 
| 172 166 |  | 
| 173 167 | 
             
                def source_cache_key(name)
         | 
| 174 | 
            -
                  name. | 
| 168 | 
            +
                  name.delete_prefix(@prefix.to_s)
         | 
| 175 169 | 
             
                end
         | 
| 176 170 |  | 
| 177 171 | 
             
                class BrotliCompressor
         | 
| @@ -62,38 +62,38 @@ describe RailsBrotliCache do | |
| 62 62 | 
             
                  end
         | 
| 63 63 |  | 
| 64 64 | 
             
                  it "for #write_multi and #read_multi" do
         | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 65 | 
            +
                    values = {
         | 
| 66 | 
            +
                      "key_1" => "val_1",
         | 
| 67 | 
            +
                      "key_2" => "val_2"
         | 
| 68 | 
            +
                    }
         | 
| 69 69 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 70 | 
            +
                    brotli_store.write_multi(values)
         | 
| 71 | 
            +
                    standard_cache.write_multi(values)
         | 
| 72 72 |  | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 73 | 
            +
                    expect(brotli_store.read("key_1")).to eq standard_cache.read("key_1")
         | 
| 74 | 
            +
                    expect(brotli_store.read("key_2")).to eq standard_cache.read("key_2")
         | 
| 75 75 |  | 
| 76 | 
            -
             | 
| 76 | 
            +
                    expect(brotli_store.read_multi("key_1", "key_2")).to eq(standard_cache.read_multi("key_1", "key_2"))
         | 
| 77 77 | 
             
                  end
         | 
| 78 78 |  | 
| 79 79 | 
             
                  it "for #fetch_multi" do
         | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 80 | 
            +
                    values = {
         | 
| 81 | 
            +
                      "key_1" => "val_1",
         | 
| 82 | 
            +
                      "key_2" => "val_2"
         | 
| 83 | 
            +
                    }
         | 
| 84 84 |  | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 85 | 
            +
                    brotli_store.fetch_multi("key_1", "key_2") do |key|
         | 
| 86 | 
            +
                      "val_#{key.split('_').last}"
         | 
| 87 | 
            +
                    end
         | 
| 88 88 |  | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 89 | 
            +
                    standard_cache.fetch_multi("key_1", "key_2") do |key|
         | 
| 90 | 
            +
                      "val_#{key.split('_').last}"
         | 
| 91 | 
            +
                    end
         | 
| 92 92 |  | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 93 | 
            +
                    expect(brotli_store.read("key_1")).to eq standard_cache.read("key_1")
         | 
| 94 | 
            +
                    expect(brotli_store.read("key_2")).to eq standard_cache.read("key_2")
         | 
| 95 95 |  | 
| 96 | 
            -
             | 
| 96 | 
            +
                    expect(brotli_store.read_multi("key_1", "key_2")).to eq(standard_cache.read_multi("key_1", "key_2"))
         | 
| 97 97 | 
             
                  end
         | 
| 98 98 | 
             
                end
         | 
| 99 99 | 
             
              end
         |