legion-cache 1.0.0
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 +7 -0
- data/.circleci/config.yml +123 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +26 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +8 -0
- data/legion-cache.gemspec +42 -0
- data/lib/legion/cache.rb +20 -0
- data/lib/legion/cache/memcached.rb +52 -0
- data/lib/legion/cache/redis.rb +50 -0
- data/lib/legion/cache/settings.rb +34 -0
- data/lib/legion/cache/version.rb +7 -0
- data/sonar-project.properties +13 -0
- metadata +232 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 9a0e98b3a109f9afe974174f40b6e881b1bc0fc44d8425170414cea1bd035f80
         | 
| 4 | 
            +
              data.tar.gz: 533023b2a19842e481108e8954e4085cb7a38c6773fd4d87482257791bce90bb
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 202568edde877bd7a9e2c0e5b245e4283f818dfbb8118a316e9fbf145ca853910c2e1da44145cc6c71698846d7d62d391495fa965708d30063bce304d4519263
         | 
| 7 | 
            +
              data.tar.gz: fbf7bfaa69f0d5f79e11d56b877481220a267d94775aeb2bcb8d243ab0baa49ecc18c6d6715ac18f5933ff3d7553ef232492c42528af548ffc264ef2d64c0c46
         | 
| @@ -0,0 +1,123 @@ | |
| 1 | 
            +
            version: 2.1
         | 
| 2 | 
            +
            orbs:
         | 
| 3 | 
            +
              ruby: circleci/ruby@0.2.1
         | 
| 4 | 
            +
              sonarcloud: sonarsource/sonarcloud@1.0.1
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            jobs:
         | 
| 7 | 
            +
              "rubocop":
         | 
| 8 | 
            +
                docker:
         | 
| 9 | 
            +
                  - image: circleci/ruby:2.7-node
         | 
| 10 | 
            +
                steps:
         | 
| 11 | 
            +
                  - checkout
         | 
| 12 | 
            +
                  - ruby/load-cache
         | 
| 13 | 
            +
                  - ruby/install-deps
         | 
| 14 | 
            +
                  - run:
         | 
| 15 | 
            +
                      name: Run Rubocop
         | 
| 16 | 
            +
                      command: bundle exec rubocop
         | 
| 17 | 
            +
                  - ruby/save-cache
         | 
| 18 | 
            +
              "ruby-two-five":
         | 
| 19 | 
            +
                docker:
         | 
| 20 | 
            +
                  - image: circleci/ruby:2.5
         | 
| 21 | 
            +
                  - image: redis:alpine
         | 
| 22 | 
            +
                  - image: memcached:1.5-alpine
         | 
| 23 | 
            +
                steps:
         | 
| 24 | 
            +
                  - checkout
         | 
| 25 | 
            +
                  - ruby/load-cache
         | 
| 26 | 
            +
                  - run:
         | 
| 27 | 
            +
                      name: update bundler
         | 
| 28 | 
            +
                      command: gem update bundler
         | 
| 29 | 
            +
                  - ruby/install-deps
         | 
| 30 | 
            +
                  - ruby/run-tests
         | 
| 31 | 
            +
                  - ruby/save-cache
         | 
| 32 | 
            +
              "ruby-two-six":
         | 
| 33 | 
            +
                docker:
         | 
| 34 | 
            +
                  - image: circleci/ruby:2.6
         | 
| 35 | 
            +
                  - image: redis:alpine
         | 
| 36 | 
            +
                  - image: memcached:1.5-alpine
         | 
| 37 | 
            +
                steps:
         | 
| 38 | 
            +
                  - checkout
         | 
| 39 | 
            +
                  - ruby/load-cache
         | 
| 40 | 
            +
                  - run:
         | 
| 41 | 
            +
                      name: update bundler
         | 
| 42 | 
            +
                      command: gem update bundler
         | 
| 43 | 
            +
                  - ruby/install-deps
         | 
| 44 | 
            +
                  - ruby/run-tests
         | 
| 45 | 
            +
                  - ruby/save-cache
         | 
| 46 | 
            +
              "ruby-two-seven":
         | 
| 47 | 
            +
                docker:
         | 
| 48 | 
            +
                  - image: circleci/ruby:2.7
         | 
| 49 | 
            +
                  - image: memcached:1.5-alpine
         | 
| 50 | 
            +
                  - image: redis:alpine
         | 
| 51 | 
            +
                steps:
         | 
| 52 | 
            +
                  - checkout
         | 
| 53 | 
            +
                  - ruby/load-cache
         | 
| 54 | 
            +
                  - ruby/install-deps
         | 
| 55 | 
            +
                  - ruby/run-tests
         | 
| 56 | 
            +
                  - ruby/save-cache
         | 
| 57 | 
            +
              "jruby-nine-two":
         | 
| 58 | 
            +
                docker:
         | 
| 59 | 
            +
                  - image: circleci/jruby:9.2-jre
         | 
| 60 | 
            +
                  - image: memcached:1.5-alpine
         | 
| 61 | 
            +
                  - image: redis:alpine
         | 
| 62 | 
            +
                steps:
         | 
| 63 | 
            +
                  - checkout
         | 
| 64 | 
            +
                  - run:
         | 
| 65 | 
            +
                      name: Bundle Install
         | 
| 66 | 
            +
                      command: bundle install
         | 
| 67 | 
            +
                  - run:
         | 
| 68 | 
            +
                      name: Run RSpec
         | 
| 69 | 
            +
                      command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
         | 
| 70 | 
            +
                      when: always
         | 
| 71 | 
            +
                  - store_test_results:
         | 
| 72 | 
            +
                      path: test-results
         | 
| 73 | 
            +
                  - sonarcloud/scan
         | 
| 74 | 
            +
              "jruby-nine-two-e":
         | 
| 75 | 
            +
                docker:
         | 
| 76 | 
            +
                  - image: circleci/jruby:9.2.11-jre
         | 
| 77 | 
            +
                  - image: memcached:1.5-alpine
         | 
| 78 | 
            +
                  - image: redis:alpine
         | 
| 79 | 
            +
                steps:
         | 
| 80 | 
            +
                  - checkout
         | 
| 81 | 
            +
                  - run:
         | 
| 82 | 
            +
                      name: Bundle Install
         | 
| 83 | 
            +
                      command: bundle install
         | 
| 84 | 
            +
                  - run:
         | 
| 85 | 
            +
                      name: Run RSpec
         | 
| 86 | 
            +
                      command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
         | 
| 87 | 
            +
                      when: always
         | 
| 88 | 
            +
                  - store_test_results:
         | 
| 89 | 
            +
                      path: test-results
         | 
| 90 | 
            +
              "sonarcloud":
         | 
| 91 | 
            +
                docker:
         | 
| 92 | 
            +
                  - image: circleci/ruby:2.7
         | 
| 93 | 
            +
                  - image: memcached:1.5-alpine
         | 
| 94 | 
            +
                  - image: redis:alpine
         | 
| 95 | 
            +
                steps:
         | 
| 96 | 
            +
                  - checkout
         | 
| 97 | 
            +
                  - ruby/load-cache
         | 
| 98 | 
            +
                  - ruby/install-deps
         | 
| 99 | 
            +
                  - ruby/run-tests
         | 
| 100 | 
            +
                  - run:
         | 
| 101 | 
            +
                      name: Run Rubocop
         | 
| 102 | 
            +
                      command: bundle exec rubocop --format=json --out=rubocop-result.json
         | 
| 103 | 
            +
                  - sonarcloud/scan
         | 
| 104 | 
            +
                  - ruby/save-cache
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            workflows:
         | 
| 107 | 
            +
              version: 2
         | 
| 108 | 
            +
              rubocop-rspec:
         | 
| 109 | 
            +
                jobs:
         | 
| 110 | 
            +
                  - rubocop
         | 
| 111 | 
            +
                  - ruby-two-five:
         | 
| 112 | 
            +
                      requires:
         | 
| 113 | 
            +
                        - rubocop
         | 
| 114 | 
            +
                  - ruby-two-six:
         | 
| 115 | 
            +
                      requires:
         | 
| 116 | 
            +
                        - ruby-two-five
         | 
| 117 | 
            +
                  - ruby-two-seven:
         | 
| 118 | 
            +
                      requires:
         | 
| 119 | 
            +
                        - ruby-two-five
         | 
| 120 | 
            +
                  - sonarcloud:
         | 
| 121 | 
            +
                      requires:
         | 
| 122 | 
            +
                        - ruby-two-seven
         | 
| 123 | 
            +
                        - ruby-two-six
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            Layout/LineLength:
         | 
| 2 | 
            +
              Max: 120
         | 
| 3 | 
            +
            Metrics/MethodLength:
         | 
| 4 | 
            +
              Max: 30
         | 
| 5 | 
            +
            Metrics/ClassLength:
         | 
| 6 | 
            +
              Max: 1500
         | 
| 7 | 
            +
            Metrics/BlockLength:
         | 
| 8 | 
            +
              Max: 50
         | 
| 9 | 
            +
            Layout/SpaceAroundEqualsInParameterDefault:
         | 
| 10 | 
            +
              EnforcedStyle: space
         | 
| 11 | 
            +
            Style/SymbolArray:
         | 
| 12 | 
            +
              Enabled: true
         | 
| 13 | 
            +
            Layout/HashAlignment:
         | 
| 14 | 
            +
              EnforcedHashRocketStyle: table
         | 
| 15 | 
            +
              EnforcedColonStyle: table
         | 
| 16 | 
            +
            Style/Documentation:
         | 
| 17 | 
            +
              Enabled: false
         | 
| 18 | 
            +
            Style/ModuleFunction:
         | 
| 19 | 
            +
              Enabled: false
         | 
| 20 | 
            +
            AllCops:
         | 
| 21 | 
            +
              TargetRubyVersion: 2.5
         | 
| 22 | 
            +
              NewCops: enable
         | 
| 23 | 
            +
            Style/FrozenStringLiteralComment:
         | 
| 24 | 
            +
              Enabled: false
         | 
| 25 | 
            +
            Naming/FileName:
         | 
| 26 | 
            +
              Enabled: false
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,86 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                legion-cache (1.0.0)
         | 
| 5 | 
            +
                  connection_pool
         | 
| 6 | 
            +
                  dalli
         | 
| 7 | 
            +
                  redis
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            GEM
         | 
| 10 | 
            +
              remote: https://rubygems.org/
         | 
| 11 | 
            +
              specs:
         | 
| 12 | 
            +
                ast (2.4.1)
         | 
| 13 | 
            +
                connection_pool (2.2.3)
         | 
| 14 | 
            +
                dalli (2.7.10)
         | 
| 15 | 
            +
                diff-lcs (1.4.4)
         | 
| 16 | 
            +
                docile (1.3.2)
         | 
| 17 | 
            +
                json (2.3.1)
         | 
| 18 | 
            +
                legion-json (1.1.0)
         | 
| 19 | 
            +
                  multi_json
         | 
| 20 | 
            +
                legion-logging (1.1.0)
         | 
| 21 | 
            +
                  rainbow (~> 3)
         | 
| 22 | 
            +
                legion-settings (1.1.0)
         | 
| 23 | 
            +
                  legion-json
         | 
| 24 | 
            +
                  legion-logging
         | 
| 25 | 
            +
                multi_json (1.15.0)
         | 
| 26 | 
            +
                parallel (1.19.2)
         | 
| 27 | 
            +
                parser (2.7.1.4)
         | 
| 28 | 
            +
                  ast (~> 2.4.1)
         | 
| 29 | 
            +
                rainbow (3.0.0)
         | 
| 30 | 
            +
                rake (13.0.1)
         | 
| 31 | 
            +
                redis (4.2.1)
         | 
| 32 | 
            +
                regexp_parser (1.7.1)
         | 
| 33 | 
            +
                rexml (3.2.4)
         | 
| 34 | 
            +
                rspec (3.9.0)
         | 
| 35 | 
            +
                  rspec-core (~> 3.9.0)
         | 
| 36 | 
            +
                  rspec-expectations (~> 3.9.0)
         | 
| 37 | 
            +
                  rspec-mocks (~> 3.9.0)
         | 
| 38 | 
            +
                rspec-core (3.9.2)
         | 
| 39 | 
            +
                  rspec-support (~> 3.9.3)
         | 
| 40 | 
            +
                rspec-expectations (3.9.2)
         | 
| 41 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 42 | 
            +
                  rspec-support (~> 3.9.0)
         | 
| 43 | 
            +
                rspec-mocks (3.9.1)
         | 
| 44 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 45 | 
            +
                  rspec-support (~> 3.9.0)
         | 
| 46 | 
            +
                rspec-support (3.9.3)
         | 
| 47 | 
            +
                rspec_junit_formatter (0.4.1)
         | 
| 48 | 
            +
                  rspec-core (>= 2, < 4, != 2.12.0)
         | 
| 49 | 
            +
                rubocop (0.88.0)
         | 
| 50 | 
            +
                  parallel (~> 1.10)
         | 
| 51 | 
            +
                  parser (>= 2.7.1.1)
         | 
| 52 | 
            +
                  rainbow (>= 2.2.2, < 4.0)
         | 
| 53 | 
            +
                  regexp_parser (>= 1.7)
         | 
| 54 | 
            +
                  rexml
         | 
| 55 | 
            +
                  rubocop-ast (>= 0.1.0, < 1.0)
         | 
| 56 | 
            +
                  ruby-progressbar (~> 1.7)
         | 
| 57 | 
            +
                  unicode-display_width (>= 1.4.0, < 2.0)
         | 
| 58 | 
            +
                rubocop-ast (0.2.0)
         | 
| 59 | 
            +
                  parser (>= 2.7.0.1)
         | 
| 60 | 
            +
                rubocop-performance (1.7.1)
         | 
| 61 | 
            +
                  rubocop (>= 0.82.0)
         | 
| 62 | 
            +
                ruby-progressbar (1.10.1)
         | 
| 63 | 
            +
                simplecov (0.17.1)
         | 
| 64 | 
            +
                  docile (~> 1.1)
         | 
| 65 | 
            +
                  json (>= 1.8, < 3)
         | 
| 66 | 
            +
                  simplecov-html (~> 0.10.0)
         | 
| 67 | 
            +
                simplecov-html (0.10.2)
         | 
| 68 | 
            +
                unicode-display_width (1.7.0)
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            PLATFORMS
         | 
| 71 | 
            +
              ruby
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            DEPENDENCIES
         | 
| 74 | 
            +
              bundler
         | 
| 75 | 
            +
              legion-cache!
         | 
| 76 | 
            +
              legion-logging
         | 
| 77 | 
            +
              legion-settings
         | 
| 78 | 
            +
              rake
         | 
| 79 | 
            +
              rspec
         | 
| 80 | 
            +
              rspec_junit_formatter
         | 
| 81 | 
            +
              rubocop
         | 
| 82 | 
            +
              rubocop-performance
         | 
| 83 | 
            +
              simplecov (< 0.18.0)
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            BUNDLED WITH
         | 
| 86 | 
            +
               2.1.4
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2020 Esity
         | 
| 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,38 @@ | |
| 1 | 
            +
            # Legion::Cache
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/legion/cache`. To experiment with that code, run `bin/console` for an interactive prompt.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```ruby
         | 
| 10 | 
            +
            gem 'legion-cache'
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            And then execute:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                $ bundle install
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Or install it yourself as:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ gem install legion-cache
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ## Usage
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             | 
| 24 | 
            +
             | 
| 25 | 
            +
            ## Development
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            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).
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ## Contributing
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://bitbucket.org/legion-io/legion-cache/issues
         | 
| 34 | 
            +
             | 
| 35 | 
            +
             | 
| 36 | 
            +
            ## License
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            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,42 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative 'lib/legion/cache/version'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |spec|
         | 
| 6 | 
            +
              spec.name          = 'legion-cache'
         | 
| 7 | 
            +
              spec.version       = Legion::Cache::VERSION
         | 
| 8 | 
            +
              spec.authors       = ['Esity']
         | 
| 9 | 
            +
              spec.email         = ['matthewdiverson@gmail.com']
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              spec.summary       = 'Legion::Cache integration'
         | 
| 12 | 
            +
              spec.description   = 'Used to connect Legion with a cache service like memcached'
         | 
| 13 | 
            +
              spec.homepage      = 'https://bitbucket.org/legion-io/legion-cache'
         | 
| 14 | 
            +
              spec.license       = 'MIT'
         | 
| 15 | 
            +
              spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              spec.metadata['homepage_uri'] = spec.homepage
         | 
| 18 | 
            +
              spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/legion-cache/src'
         | 
| 19 | 
            +
              spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/legion-cache/src/master/CHANGELOG.md'
         | 
| 20 | 
            +
              spec.metadata['wiki_uri'] = 'https://bitbucket.org/legion-io/legion-cache/wiki'
         | 
| 21 | 
            +
              spec.metadata['bug_tracker_uri'] = 'https://bitbucket.org/legion-io/legion-cache/issues'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              spec.files = Dir.chdir(File.expand_path(__dir__)) do
         | 
| 24 | 
            +
                `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 27 | 
            +
              spec.require_paths = ['lib']
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              spec.add_development_dependency 'bundler'
         | 
| 30 | 
            +
              spec.add_development_dependency 'legion-logging'
         | 
| 31 | 
            +
              spec.add_development_dependency 'legion-settings'
         | 
| 32 | 
            +
              spec.add_development_dependency 'rake'
         | 
| 33 | 
            +
              spec.add_development_dependency 'rspec'
         | 
| 34 | 
            +
              spec.add_development_dependency 'rspec_junit_formatter'
         | 
| 35 | 
            +
              spec.add_development_dependency 'rubocop'
         | 
| 36 | 
            +
              spec.add_development_dependency 'rubocop-performance'
         | 
| 37 | 
            +
              spec.add_development_dependency 'simplecov', '< 0.18.0'
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              spec.add_dependency 'connection_pool'
         | 
| 40 | 
            +
              spec.add_dependency 'dalli'
         | 
| 41 | 
            +
              spec.add_dependency 'redis'
         | 
| 42 | 
            +
            end
         | 
    
        data/lib/legion/cache.rb
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            require_relative 'cache/version'
         | 
| 2 | 
            +
            require_relative 'cache/settings'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require_relative 'cache/memcached'
         | 
| 5 | 
            +
            require_relative 'cache/redis'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Legion
         | 
| 8 | 
            +
              module Cache
         | 
| 9 | 
            +
                class << self
         | 
| 10 | 
            +
                  include Legion::Cache::Memcached if Legion::Settings[:cache][:driver] == 'dalli'
         | 
| 11 | 
            +
                  include Legion::Cache::Redis if Legion::Settings[:cache][:driver] == 'redis'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def shutdown
         | 
| 14 | 
            +
                    Legion::Logging.info 'Shutting down Legion::Cache'
         | 
| 15 | 
            +
                    close
         | 
| 16 | 
            +
                    Legion::Settings[:cache][:connected] = false
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            require 'dalli'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Legion
         | 
| 4 | 
            +
              module Cache
         | 
| 5 | 
            +
                module Memcached
         | 
| 6 | 
            +
                  extend self
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def client(servers: Legion::Settings[:cache][:servers], **opts)
         | 
| 9 | 
            +
                    return @client unless @client.nil?
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    Dalli.logger = Legion::Logging
         | 
| 12 | 
            +
                    @client = Dalli::Client.new(servers, Legion::Settings[:cache].merge(opts))
         | 
| 13 | 
            +
                    @connected = true
         | 
| 14 | 
            +
                    @client
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def connected?
         | 
| 18 | 
            +
                    @connected ||= false
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def close
         | 
| 22 | 
            +
                    client.close
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def restart
         | 
| 26 | 
            +
                    close
         | 
| 27 | 
            +
                    @client = nil
         | 
| 28 | 
            +
                    client
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def get(key)
         | 
| 32 | 
            +
                    client.get(key)
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def fetch(key, ttl = nil)
         | 
| 36 | 
            +
                    client.fetch(key, ttl)
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def set(key, value, ttl = 180)
         | 
| 40 | 
            +
                    client.set(key, value, ttl).positive?
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def delete(key)
         | 
| 44 | 
            +
                    client.delete(key) == true
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  def flush(delay = 0)
         | 
| 48 | 
            +
                    client.flush(delay).first
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
            end
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            require 'redis'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Legion
         | 
| 4 | 
            +
              module Cache
         | 
| 5 | 
            +
                module Redis
         | 
| 6 | 
            +
                  extend self
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def client
         | 
| 9 | 
            +
                    return @client unless @client.nil?
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    @client = ::Redis.new
         | 
| 12 | 
            +
                    @connected = true
         | 
| 13 | 
            +
                    @client
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def connected?
         | 
| 17 | 
            +
                    @connected ||= false
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def close
         | 
| 21 | 
            +
                    client.close
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def restart
         | 
| 25 | 
            +
                    close
         | 
| 26 | 
            +
                    @client = nil
         | 
| 27 | 
            +
                    client
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def get(key)
         | 
| 31 | 
            +
                    client.get(key)
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  alias fetch get
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def set(key, value, ttl: nil)
         | 
| 36 | 
            +
                    args = {}
         | 
| 37 | 
            +
                    args[:ex] = ttl unless ttl.nil?
         | 
| 38 | 
            +
                    client.set(key, value, **args) == 'OK'
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def delete(key)
         | 
| 42 | 
            +
                    client.del(key) == 1
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  def flush
         | 
| 46 | 
            +
                    client.flushdb == 'OK'
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            module Legion
         | 
| 2 | 
            +
              module Cache
         | 
| 3 | 
            +
                module Settings
         | 
| 4 | 
            +
                  Legion::Settings.merge_settings(:cache, default) if Legion::Settings.method_defined? :merge_settings
         | 
| 5 | 
            +
                  def self.default
         | 
| 6 | 
            +
                    {
         | 
| 7 | 
            +
                      driver:     driver,
         | 
| 8 | 
            +
                      servers:    ['127.0.0.1:11211'],
         | 
| 9 | 
            +
                      connected:  false,
         | 
| 10 | 
            +
                      enabled:    true,
         | 
| 11 | 
            +
                      namespace:  'legion',
         | 
| 12 | 
            +
                      compress:   false,
         | 
| 13 | 
            +
                      failover:   true,
         | 
| 14 | 
            +
                      threadsafe: true,
         | 
| 15 | 
            +
                      expires_in: 0,
         | 
| 16 | 
            +
                      cache_nils: false,
         | 
| 17 | 
            +
                      pool_size:  5,
         | 
| 18 | 
            +
                      serializer: Legion::JSON
         | 
| 19 | 
            +
                    }
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def self.driver(prefer = 'dalli')
         | 
| 23 | 
            +
                    secondary = prefer == 'dalli' ? 'redis' : 'dalli'
         | 
| 24 | 
            +
                    if Gem::Specification.find_all_by_name(prefer).count.positive?
         | 
| 25 | 
            +
                      prefer
         | 
| 26 | 
            +
                    elsif Gem::Specification.find_all_by_name(secondary).count.positive?
         | 
| 27 | 
            +
                      secondary
         | 
| 28 | 
            +
                    else
         | 
| 29 | 
            +
                      raise NameError('Legion::Cache.driver is nil')
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            sonar.projectKey=legion-io_legion-cache
         | 
| 2 | 
            +
            sonar.organization=legion-io
         | 
| 3 | 
            +
            sonar.projectName=Legion::Cache
         | 
| 4 | 
            +
            sonar.sources=.
         | 
| 5 | 
            +
            sonar.exclusions=vendor/**
         | 
| 6 | 
            +
            sonar.coverage.exclusions=spec/**
         | 
| 7 | 
            +
            sonar.cpd.exclusions=spec/**
         | 
| 8 | 
            +
            sonar.ruby.coverage.reportPath=coverage/.resultset.json
         | 
| 9 | 
            +
            sonar.ruby.file.suffixes=rb,ruby
         | 
| 10 | 
            +
            sonar.ruby.coverage.framework=RSpec
         | 
| 11 | 
            +
            sonar.ruby.rubocopConfig=.rubocop.yml
         | 
| 12 | 
            +
            sonar.ruby.rubocop.reportPath=rubocop-result.json
         | 
| 13 | 
            +
            sonar.ruby.rubocop.filePath=.
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,232 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: legion-cache
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Esity
         | 
| 8 | 
            +
            autorequire:
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2020-07-21 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: '0'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: legion-logging
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: legion-settings
         | 
| 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 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rake
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rspec
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ">="
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: rspec_junit_formatter
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ">="
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ">="
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: rubocop
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: rubocop-performance
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ">="
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ">="
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: simplecov
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - "<"
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: 0.18.0
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "<"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: 0.18.0
         | 
| 139 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            +
              name: connection_pool
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - ">="
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '0'
         | 
| 146 | 
            +
              type: :runtime
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - ">="
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '0'
         | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: dalli
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - ">="
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '0'
         | 
| 160 | 
            +
              type: :runtime
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - ">="
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '0'
         | 
| 167 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            +
              name: redis
         | 
| 169 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 | 
            +
                requirements:
         | 
| 171 | 
            +
                - - ">="
         | 
| 172 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            +
                    version: '0'
         | 
| 174 | 
            +
              type: :runtime
         | 
| 175 | 
            +
              prerelease: false
         | 
| 176 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 | 
            +
                requirements:
         | 
| 178 | 
            +
                - - ">="
         | 
| 179 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                    version: '0'
         | 
| 181 | 
            +
            description: Used to connect Legion with a cache service like memcached
         | 
| 182 | 
            +
            email:
         | 
| 183 | 
            +
            - matthewdiverson@gmail.com
         | 
| 184 | 
            +
            executables: []
         | 
| 185 | 
            +
            extensions: []
         | 
| 186 | 
            +
            extra_rdoc_files: []
         | 
| 187 | 
            +
            files:
         | 
| 188 | 
            +
            - ".circleci/config.yml"
         | 
| 189 | 
            +
            - ".gitignore"
         | 
| 190 | 
            +
            - ".rspec"
         | 
| 191 | 
            +
            - ".rubocop.yml"
         | 
| 192 | 
            +
            - Gemfile
         | 
| 193 | 
            +
            - Gemfile.lock
         | 
| 194 | 
            +
            - LICENSE.txt
         | 
| 195 | 
            +
            - README.md
         | 
| 196 | 
            +
            - Rakefile
         | 
| 197 | 
            +
            - legion-cache.gemspec
         | 
| 198 | 
            +
            - lib/legion/cache.rb
         | 
| 199 | 
            +
            - lib/legion/cache/memcached.rb
         | 
| 200 | 
            +
            - lib/legion/cache/redis.rb
         | 
| 201 | 
            +
            - lib/legion/cache/settings.rb
         | 
| 202 | 
            +
            - lib/legion/cache/version.rb
         | 
| 203 | 
            +
            - sonar-project.properties
         | 
| 204 | 
            +
            homepage: https://bitbucket.org/legion-io/legion-cache
         | 
| 205 | 
            +
            licenses:
         | 
| 206 | 
            +
            - MIT
         | 
| 207 | 
            +
            metadata:
         | 
| 208 | 
            +
              homepage_uri: https://bitbucket.org/legion-io/legion-cache
         | 
| 209 | 
            +
              source_code_uri: https://bitbucket.org/legion-io/legion-cache/src
         | 
| 210 | 
            +
              changelog_uri: https://bitbucket.org/legion-io/legion-cache/src/master/CHANGELOG.md
         | 
| 211 | 
            +
              wiki_uri: https://bitbucket.org/legion-io/legion-cache/wiki
         | 
| 212 | 
            +
              bug_tracker_uri: https://bitbucket.org/legion-io/legion-cache/issues
         | 
| 213 | 
            +
            post_install_message:
         | 
| 214 | 
            +
            rdoc_options: []
         | 
| 215 | 
            +
            require_paths:
         | 
| 216 | 
            +
            - lib
         | 
| 217 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 218 | 
            +
              requirements:
         | 
| 219 | 
            +
              - - ">="
         | 
| 220 | 
            +
                - !ruby/object:Gem::Version
         | 
| 221 | 
            +
                  version: 2.5.0
         | 
| 222 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 223 | 
            +
              requirements:
         | 
| 224 | 
            +
              - - ">="
         | 
| 225 | 
            +
                - !ruby/object:Gem::Version
         | 
| 226 | 
            +
                  version: '0'
         | 
| 227 | 
            +
            requirements: []
         | 
| 228 | 
            +
            rubygems_version: 3.1.2
         | 
| 229 | 
            +
            signing_key:
         | 
| 230 | 
            +
            specification_version: 4
         | 
| 231 | 
            +
            summary: Legion::Cache integration
         | 
| 232 | 
            +
            test_files: []
         |