dalli-store-with-cas 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6e6ae334ee9219c881b980ae5126911c0c10aeb
4
+ data.tar.gz: 664db479eeb84b8178c497ad4ebd050455e8840c
5
+ SHA512:
6
+ metadata.gz: c59bbdd570f905370b677393d863a33ec96bb72851f7d5d20584214411713caabf8ca6cac640d2b5cf89120202e7d69c8f8d63662cc0d5d2b614c9884f72b3e9
7
+ data.tar.gz: '0582e569732cdac98966a92ea0b61b854bdbf0ae01dd1f6a645c03cd03f9e983435aac7b88b05aeb61a5300c9b876175a2531a2d8f168bc30249f036babb405a'
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ version = ENV["AS_VERSION"] || "5.2.0.rc1"
5
+ as_version = case version
6
+ when "master"
7
+ { github: "rails/rails" }
8
+ else
9
+ "~> #{version}"
10
+ end
11
+
12
+ gem "activesupport", as_version
13
+
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dalli-store-with-cas (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (5.2.3)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ concurrent-ruby (1.1.5)
15
+ dalli (2.7.10)
16
+ i18n (1.6.0)
17
+ concurrent-ruby (~> 1.0)
18
+ minitest (5.11.3)
19
+ rake (10.5.0)
20
+ thread_safe (0.3.6)
21
+ tzinfo (1.2.5)
22
+ thread_safe (~> 0.1)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ activesupport (~> 5.2.0.rc1)
29
+ bundler (~> 1.16)
30
+ dalli
31
+ dalli-store-with-cas!
32
+ rake (~> 10.0)
33
+
34
+ BUNDLED WITH
35
+ 1.16.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Misha Conway
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # DalliStoreWithCas
2
+
3
+ Provides ActiveSupport::Cache::DalliStoreWithCas which inherits dalli's ActiveSupport::Cache::DalliStore cache adapter
4
+ extends it with two new methods, cas and cas_multi. These methods are specifically implemented to be compatible with IdentityCache
5
+ so it's good news for
6
+
7
+ - those wishing to use Dalli with IdentityCache with full support
8
+ (with normal DalliStore, IdentityCache activates its 'fallback fetcher',
9
+ which doesn't protect against various race conditions leading to corrupted data
10
+
11
+ - those who just want cas support on DalliStore
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'dalli-store-with-cas'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install dalli-store-with-cas
28
+
29
+ ## Usage
30
+
31
+ Usage instructions to be added
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Tests
40
+
41
+ Tests can be run via
42
+
43
+ ruby -Ilib:test test/test_dalli_store_with_cas.rb
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/MishaConway/dalli-store-with-cas.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dalli/store/with/with/cas"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "active_support/cache/dalli_store_with_cas"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dalli-store-with-cas"
8
+ spec.version = ActiveSupport::Cache::DalliStoreWithCas::DALLI_STORE_WITH_CAS_VERSION
9
+ spec.authors = ["Misha Conway"]
10
+ spec.email = ["mishaAconway@gmail.com"]
11
+
12
+ spec.summary = %q{A version of ActiveSupport::Cache::DalliStore with CAS support compatible with IdentityCache}
13
+ spec.homepage = "https://github.com/MishaConway/dalli-store-with-cas"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency 'dalli'
28
+ end
@@ -0,0 +1,55 @@
1
+ require 'active_support/cache/dalli_store'
2
+ require 'dalli/cas/client'
3
+
4
+ module ActiveSupport
5
+ module Cache
6
+ class DalliStoreWithCas < DalliStore
7
+ DALLI_STORE_WITH_CAS_VERSION = "0.0.1"
8
+
9
+ def cas(name, options = {})
10
+ cas_multi(name, options) { |kv| { kv.keys.first => yield(kv.values.first) } }
11
+ end
12
+
13
+ def cas_multi(*names, **options)
14
+ return if names.empty?
15
+
16
+ keys_to_names = Hash[names.map { |name| [namespaced_key(name, options), name] }]
17
+
18
+ instrument_with_log(:cas_multi, names, options) do
19
+ with do |c|
20
+ keys_to_value_and_cas = c.get_multi_cas(keys_to_names.keys)
21
+
22
+ values_to_yield = keys_to_value_and_cas.map do |key, value_and_cas|
23
+ [key, value_and_cas.first]
24
+ end.to_h
25
+ new_values = yield values_to_yield
26
+
27
+ successfully_updated_values = {}
28
+ found_corresponding_key = false
29
+
30
+ new_values.each do |k, v|
31
+ value_and_cas = keys_to_value_and_cas[k]
32
+ if value_and_cas
33
+ found_corresponding_key = true
34
+ current_cas = value_and_cas.last
35
+ if c.set_cas(k, v, current_cas, nil, options)
36
+ successfully_updated_values[k] = v
37
+ end
38
+ end
39
+ end
40
+
41
+ !found_corresponding_key || successfully_updated_values.present?
42
+ end
43
+ end
44
+
45
+ rescue Dalli::DalliError => e
46
+ log_dalli_error(e)
47
+ instrument_error(e) if instrument_errors?
48
+ raise if raise_errors?
49
+ false
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dalli-store-with-cas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Misha Conway
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dalli
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - mishaAconway@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - dalli-store-with-cas.gemspec
71
+ - lib/active_support/cache/dalli_store_with_cas.rb
72
+ homepage: https://github.com/MishaConway/dalli-store-with-cas
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.14
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: A version of ActiveSupport::Cache::DalliStore with CAS support compatible
96
+ with IdentityCache
97
+ test_files: []