cache_store 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 93720eeece64e0348cdd1429dd754b61e585b149
4
- data.tar.gz: a8e5be29d169ab8f6c591c74b318f7792edcb2cc
2
+ SHA256:
3
+ metadata.gz: 96b4d58f79c8500e2ae155154e37e991d47f42115335433f57c20a48d95241a2
4
+ data.tar.gz: 3bb2dec24c9370c6467274b209a522f734c8c2e4bcc2d275fc688cd51cefcb9f
5
5
  SHA512:
6
- metadata.gz: 85e5d98a7b73fd8f70b376d70b37975b7394e98dc9eee1130021a3e09be8bdb85edf44022f519fe34da7253e931300159f29492b766e14c51b46e70a807d8d77
7
- data.tar.gz: 45cb0f6d93159bea98aac9b1b9abbc0771b4778c78de191cd9697f4836ab75faff34836bdfb6ba0c1eaba1517216026e4b356b2271d9df24f5d02251f8a4be46
6
+ metadata.gz: e0a3b3e8ad71b2101a86135fcda9b0fc8e26c5446b1a025673e817820a2a98c920be642a78bf7690f638b84337209c0eb4a93e561aab86cd3c69bed7067dcee6
7
+ data.tar.gz: 20dfd76b3a3e3bd1e80c2cd30f83aa0607b9edde50873ec102ccc68b272e2049f6f6e4a2795a383fcb813c26f1577c4f0029c75a2806ef0b0aac1b4a60c3a62b
data/.gitignore CHANGED
@@ -1,9 +1,12 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ .bundle
2
+ .yardoc
3
+ Gemfile.lock
4
+ _yardoc/
5
+ doc/
6
+ pkg/
7
+ spec/reports/
8
+ tmp/
9
+ *.swp
10
+ idea/
11
+ coverage/
12
+ .DS_Store
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
2
  --require spec_helper
3
- --format doc
@@ -0,0 +1,26 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.5
4
+ cache: bundler
5
+ before_install:
6
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
7
+ - gem install bundler -v '< 2'
8
+ before_script:
9
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
10
+ > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ - "./cc-test-reporter before-build"
13
+ after_script:
14
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
15
+ deploy:
16
+ provider: rubygems
17
+ api_key:
18
+ secure: uY9g2fOoVtJgbSOX+6NXhmhhHPnW/nYw9XBrCLXD0OC2yK6pjD/CnB6u7AruWz0Am0m4oc0elH/nar+BW0iwceRlOFD95jJw5TSXjZSrAiPX7jzpvwNOtn7hHz5vnIVGfxn85oOHgvwAE73PJn24F3LrdpWy6lPp7MocT7CKHJimedxCG8iyH/pfXqu5fM9aqgZcLpImY8VhhFkZaUWPwdvqzirYV/vV+qzLFiLkB78fWhbkjOVdDASKYCIjJvNQvDeuUiUTgrKoDWWMoaV4E7e40VvdeuwI9lNgcUw+hkThD7HAuvJvla4VugFXny/AVkZ5KvPXBaYFH7ZkHt02RDlyV0Ri8yiUDiWniaWMMYuZyrlFtCSwt3N8IBcd+EXs12+y4cFaU0o8c6HMlWfXxutiuWjn60yW2VE2cgoNDi+DyC6NUGbX5v6Soeexw+WQG9q9o8q/Oa2QrGbWC5RgTQUmvFQR6GUe+7WcWfL5D1bxAxKi7GbrKwclKZmM65UznZose/qSgZscGBZSiaa11wFh+YWuO9IsVyAZ5pdGrmCod3hAtX4fkPWhgsX2QL2kgL1XOJmboh0DZpiardznygEUBBWpTN1PEBYDxpkL2drkfDrCOrjImvrQEUW8CIhvIft2vTzk5KWmUxcgphUcjYTawBC+3hTVJpbjPSHTBis=
19
+ gem: cache_store
20
+ on:
21
+ tags: true
22
+ repo: Sage/cache_store
23
+ condition: "$TRAVIS_RUBY_VERSION == 2.3.5"
24
+ env:
25
+ global:
26
+ secure: O/lMTYW0M8jEIzVagAkxQWIckfJTgYZTdYw4QNg5FUKjFEmj5ECZIjYT+tGFvut3juhd66kyA2iGOSyuqjK+Hl6qhBz723cEE6eBr2Y2l0pUn5WDvHhhFAF2c0PYZNBrlHP2q4ug3fsYwxDrBMSZVv911wmUKGIGyT2U91hNa6QXduvG+dkYH4vZsQi+2cQbIGVs2TQGzvikt1jGYaeYiqxfTrlGoxQW0l6XRufckfn9vVCDaZ+zbC3MixKkIufc9TR5RCGdZgEU22T7QSwwBDk2YKvHCsSQgiX10ZHHD84xrX88eWYilVDJs6IesKp1Oy2dnSsFX7hXINS1T96LWTfFzoK3mxwQWtDqYm96Eksz3LQIyvDcmOGSXxBm5y3YVn1s3kimNX4m0HnkZyXvt+hlzmuhbfSiJyQKoAzDK1tkG6FYueAgfMBtB3+6eiIxt1xNODJDR29OZVGLvauhOMLuyyPKzUnrp0VCYBSEecZ7q4bAWRsAEVLQonqeNIcmLtnoXE7HVXUFnJdtIuyRofguQhjrfeY3h/wCXO0Cm7V61dKjoN+i59V0e+jqDXa+ucjCT7uvOgQTJ9QWzJiHUxXY+twTkO82io0Z2krQsk12lTTirNOEzPYM47q08ajQUHAFEjnSxjC907cWuLjfkZVLR2z3R/90MtVDUyZTWN0=
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in cache_store_redis.gemspec
3
+ # Specify your gem's dependencies in cache_store.gemspec
4
4
  gemspec
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 vaughanbrittonsage
3
+ Copyright (c) 2018 Sage Group Plc
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,177 @@
1
+ # CacheStore
2
+
3
+ [![Build Status](https://travis-ci.org/Sage/cache_store.svg?branch=master)](https://travis-ci.org/Sage/cache_store)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/1b7be47117254e31c5f8/maintainability)](https://codeclimate.com/github/Sage/cache_store/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/1b7be47117254e31c5f8/test_coverage)](https://codeclimate.com/github/Sage/cache_store/test_coverage)
6
+ [![Gem Version](https://badge.fury.io/rb/cache_store.svg)](https://badge.fury.io/rb/cache_store)
7
+
8
+ Welcome to CacheStore!
9
+
10
+ This is the base for a cache framework that includes a basic in memory cache store, along with a dependency contract for additional provider implementations plugins.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'cache_store'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```bash
23
+ $ bundle
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```bash
29
+ $ gem install cache_store
30
+ ```
31
+
32
+ ## Implementations
33
+
34
+ All cache store implementations adhere to the following contract:
35
+
36
+
37
+ ```ruby
38
+ class CacheStore
39
+
40
+ def set(key, value, expires_in = 0)
41
+
42
+ end
43
+
44
+ def get(key, expires_in = 0, &block)
45
+
46
+ end
47
+
48
+ def remove(key)
49
+
50
+ end
51
+
52
+ def exist?(key)
53
+
54
+ end
55
+ end
56
+ ```
57
+
58
+ **#set**
59
+
60
+ This method is called to store a value in the cache store for a unique key.
61
+
62
+ Params:
63
+
64
+ - **key** [String]
65
+ This is the unique key to reference the value being set within this cache store
66
+ - **value** [Object]
67
+ This is the value to set within this cache store.
68
+ - **expires_in** [Integer] [Optional]
69
+ This is the number of seconds from the current time that this value should expire.
70
+
71
+ Example:
72
+
73
+ #set with expires_in specified
74
+ cache_store.set('country_code', 'en-GB', 180)
75
+
76
+
77
+ > The above example will store the **value** `en-GB` under the **key**
78
+ > `country_code` for **expiry** time of 180 seconds (3 minutes).
79
+ > Any requests to the `cache_store` for the `country_code` key within the next 180 seconds (3 minutes) will return the `en-GB` value.
80
+ > Requests for the key after the expiry time will return **nil** if no hydration block has been specified in the request.
81
+ > If you don't specify an **expires_in** parameter then the value stored will not expire for the lifespan of the `cache_store`.
82
+
83
+ **#get**
84
+
85
+ This method is called to request a value from the cache store for a unique key.
86
+
87
+ Params:
88
+
89
+ - **key** [String]
90
+ This is the unique key of the value you want to fetch from within the cache store.
91
+ - **expires_in** [Integer] [Optional]
92
+ This is the number of seconds from the current time that this value should expire.
93
+
94
+ > (This is used in conjunction with the hydrate block to populate the cache key if it is empty.)
95
+
96
+ - **&block** [Block] [Optional]
97
+ This is the hydration block that when specified is used to populate the `cache_store` with the value for the specified key.
98
+
99
+ Examples:
100
+
101
+ ```ruby
102
+ # example without a hydration block
103
+ value = cache_store.get('country_code')
104
+ ```
105
+
106
+ > This would return the **value** stored for the `country_code` key or **nil** if the value had expired or was not found.
107
+
108
+ ```ruby
109
+ # example with a hydration block
110
+ value = cache_store.get('country_code', 180) do
111
+ {
112
+ return 'en-GB'
113
+ }
114
+ ```
115
+
116
+ > This would execute the hydration block if the value was not found for the specified key or if the value had expired.
117
+
118
+ **#remove**
119
+
120
+ This method is called to remove a value from the cache store by it's unique key.
121
+
122
+ Params:
123
+
124
+ - **key** [String] This is the unique key of the item to remove from the cache store.
125
+
126
+ Example:
127
+
128
+ ```ruby
129
+ cache_store.remove('country_code')
130
+ ```
131
+
132
+ **#exist?**
133
+
134
+ This method is called to check if a value has been stored in the cache store for a specific key.
135
+
136
+ Params:
137
+
138
+ **key** [String]
139
+ This is the unique key of the value to check for.
140
+
141
+ Example:
142
+
143
+ ```ruby
144
+ if cache_store.exist?('country_code')
145
+ # ....do logic here
146
+ end
147
+ ```
148
+
149
+ ##LocalCacheStore
150
+
151
+ The local cache store is a ruby in memory cache store that has no dependency on rails or any other frameworks. Multiple instances of the cache store can be created as required to maintain isolated cache stores, which are perfect for development and testing when your production application cache uses redis or memcached etc as a distributed cache.
152
+
153
+ ```ruby
154
+ # create a new instance of the cache store
155
+ cache_store = LocalCacheStore.new
156
+ ```
157
+
158
+ > **CacheStore** works perfectly with **Sinject** a dependency injection framework allowing you to switch the cache store implementations used for different environments.
159
+
160
+ ## Development
161
+
162
+ 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.
163
+
164
+ 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).
165
+
166
+ ## Contributing
167
+
168
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sage/cache_store. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
169
+
170
+
171
+ ## License
172
+
173
+ Cache Store is available as open source under the terms of the
174
+ [MIT licence](LICENSE).
175
+
176
+ Copyright (c) 2018 Sage Group Plc. All rights reserved.
177
+
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -4,23 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'cache_store/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "cache_store"
7
+ spec.name = 'cache_store'
8
8
  spec.version = CacheStore::VERSION
9
- spec.authors = ["vaughanbrittonsage"]
10
- spec.email = ["vaughan.britton@sage.com"]
9
+ spec.authors = ['vaughanbrittonsage']
10
+ spec.email = ['vaughan.britton@sage.com']
11
11
 
12
12
  spec.summary = 'This is the base for a cache framework that includes a basic in memory cache store, along with a dependency contract for additional provider implementations plugins.'
13
13
  spec.description = 'This is the base for a cache framework that includes a basic in memory cache store, along with a dependency contract for additional provider implementations plugins.'
14
- spec.homepage = "https://github.com/vaughanbrittonsage/cache_store_redis"
15
- spec.license = "MIT"
14
+ spec.homepage = 'https://github.com/sage/cache_store_redis'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.0"
20
+ spec.require_paths = ['lib']
25
21
 
22
+ spec.add_development_dependency 'bundler', '~> 1.11'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'simplecov'
26
26
  end
@@ -61,7 +61,7 @@ class LocalCacheStore
61
61
  # @param key [String] Unique key to reference the value to fetch from within this cache store.
62
62
  # @param &block [Block] This block is provided to populate this cache store with the value for the request key when it is not found.
63
63
  # @return [Object] The value for the specified unique key within the cache store.
64
- def get(key, expires_in = 0)
64
+ def get(key, expires_in = 0, &block)
65
65
  item = @store[key]
66
66
  if item
67
67
  if item[:expires] && item[:expires] < Time.now # An expired entry has been found
@@ -1,3 +1,3 @@
1
1
  module CacheStore
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-13 00:00:00.000000000 Z
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,16 +42,30 @@ dependencies:
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
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
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '3.0'
68
+ version: '0'
55
69
  description: This is the base for a cache framework that includes a basic in memory
56
70
  cache store, along with a dependency contract for additional provider implementations
57
71
  plugins.
@@ -63,16 +77,18 @@ extra_rdoc_files: []
63
77
  files:
64
78
  - ".gitignore"
65
79
  - ".rspec"
80
+ - ".travis.yml"
66
81
  - CODE_OF_CONDUCT.md
67
82
  - Gemfile
68
- - LICENSE.txt
83
+ - LICENSE
84
+ - README.md
69
85
  - Rakefile
70
86
  - bin/console
71
87
  - bin/setup
72
88
  - cache_store.gemspec
73
89
  - lib/cache_store.rb
74
90
  - lib/cache_store/version.rb
75
- homepage: https://github.com/vaughanbrittonsage/cache_store_redis
91
+ homepage: https://github.com/sage/cache_store_redis
76
92
  licenses:
77
93
  - MIT
78
94
  metadata: {}
@@ -92,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
108
  version: '0'
93
109
  requirements: []
94
110
  rubyforge_project:
95
- rubygems_version: 2.5.1
111
+ rubygems_version: 2.7.7
96
112
  signing_key:
97
113
  specification_version: 4
98
114
  summary: This is the base for a cache framework that includes a basic in memory cache