cache_store 0.1.2 → 0.1.3

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
2
  SHA1:
3
- metadata.gz: 0e31165c24f765895e95602470df71600233e061
4
- data.tar.gz: e22ea9e05ac807c3e1cdd386e5af07ef6a960201
3
+ metadata.gz: a97d6690cc883c5779e36a5dd2a8aaec2dd35e74
4
+ data.tar.gz: 42b72ea091345e5ff7b865a01d3744a231e96c37
5
5
  SHA512:
6
- metadata.gz: 832795a803518e68cecab22feb96c4c0ad81eb163cee90e2ff973576dc3fa3631e8bbe20120c13be23f2b1e66c049f99075a4363774753a9855d8e8e12fb3b89
7
- data.tar.gz: e1bfd898f9f849daa329db905e3db85ad418100c704ec0d32199e2d523ca44b6e22a55628cd058d56cb8caaa0cbb3fd6ae70d26364c078b8fcbd29786f957e8f
6
+ metadata.gz: 186617848b9816fa410882e3c936c43cad4183a1d2a71c9d0833317cf3bdc0dd4d81c66a53e7c79af0cdd1b77808c957ebedc02940c2ddf5aff29551d05c928b
7
+ data.tar.gz: b5923f99d9a10725ed3b038964e8a453df32454756fdb1a91a7dae64568b880afa094e9dc0bd4bb42ddc3cca624b91a0049d6fb0355f886e7500ec9672d2ccb2
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --require spec_helper
3
+ --format doc
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in cache_store.gemspec
3
+ # Specify your gem's dependencies in cache_store_redis.gemspec
4
4
  gemspec
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
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"
14
+ spec.homepage = "https://github.com/vaughanbrittonsage/cache_store_redis"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
+
25
26
  end
@@ -46,7 +46,7 @@ class LocalCacheStore
46
46
 
47
47
  attr_accessor :store
48
48
 
49
- def initialize(namespace = '')
49
+ def initialize(namespace = nil)
50
50
  @store = Array.new
51
51
  @namespace = namespace
52
52
  end
@@ -121,6 +121,12 @@ class LocalCacheStore
121
121
  private
122
122
 
123
123
  def build_key(key)
124
- @namespace + key.to_s
124
+ k = ''
125
+ if @namespace != nil
126
+ k = @namespace + ':' + key.to_s
127
+ elsif
128
+ k = key.to_s
129
+ end
130
+ k
125
131
  end
126
132
  end
@@ -1,3 +1,3 @@
1
1
  module CacheStore
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-25 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,14 +66,13 @@ files:
66
66
  - CODE_OF_CONDUCT.md
67
67
  - Gemfile
68
68
  - LICENSE.txt
69
- - README.md
70
69
  - Rakefile
71
70
  - bin/console
72
71
  - bin/setup
73
72
  - cache_store.gemspec
74
73
  - lib/cache_store.rb
75
74
  - lib/cache_store/version.rb
76
- homepage: https://github.com/vaughanbrittonsage/cache_store
75
+ homepage: https://github.com/vaughanbrittonsage/cache_store_redis
77
76
  licenses:
78
77
  - MIT
79
78
  metadata: {}
data/README.md DELETED
@@ -1,156 +0,0 @@
1
- # CacheStore
2
-
3
- Welcome to CacheStore!
4
-
5
- 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.
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'cache_store'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install cache_store
22
-
23
- ## Implementations
24
-
25
- All cache store implementations adhere to the following contract:
26
-
27
-
28
- class CacheStoreContract
29
-
30
- def set(key, value, expires_in = 0)
31
-
32
- end
33
-
34
- def get(key, expires_in = 0, &block)
35
-
36
- end
37
-
38
- def remove(key)
39
-
40
- end
41
-
42
- def exist?(key)
43
-
44
- end
45
- end
46
-
47
-
48
- **#set**
49
-
50
- This method is called to store a value in the cache store for a unique key.
51
-
52
- Params:
53
-
54
- - **key** [String]
55
- This is the unique key to reference the value being set within this cache store
56
- - **value** [Object]
57
- This is the value to set within this cache store.
58
- - **expires_in** [Integer] [Optional]
59
- This is the number of seconds from the current time that this value should expire.
60
-
61
- Example:
62
-
63
- #set with expires_in specified
64
- cache_store.set('country_code', 'en-GB', 180)
65
-
66
-
67
- > The above example will store the **value** 'en-GB' under the **key**
68
- > 'country_code' for **expiry** time of 180 seconds (2minutes).
69
- > Any requests to the cache_store for the 'country_code' key within the next 180 seconds (2minutes) will return the 'en-GB' value.
70
- > Requests for the key after the expiry time will return **nil** if no hydration block has been specified in the request.
71
- > If you don't specify an **expires_in** parameter then the value stored will not expire for the lifespan of the cache_store.
72
-
73
- **#get**
74
-
75
- This method is called to request a value from the cache store for a unique key.
76
-
77
- Params:
78
-
79
- - **key** [String]
80
- This is the unique key of the value you want to fetch from within the cache store.
81
- - **expires_in** [Integer] [Optional]
82
- This is the number of seconds from the current time that this value should expire.
83
-
84
- > (This is used in conjunction with the hydrate block to populate the cache key if it is empty.)
85
-
86
- - **&block** [Block] [Optional]
87
- This is the hydration block that when specified is used to populate the cache_store with the value for the specified key.
88
-
89
- Examples:
90
-
91
- #example without a hydration block
92
- value = cache_store.get('country_code')
93
-
94
- > This would return the **value** stored for the 'country_code' key or **nil** if the value had expired or was not found.
95
-
96
- #example with a hydration block
97
- value = cache_store.get('country_code', 180) do
98
- {
99
- return 'en-GB'
100
- }
101
-
102
- > This would execute the hydration block if the value was not found for the specified key or if the value had expired.
103
-
104
- **#remove**
105
-
106
- This method is called to remove a value from the cache store by it's unique key.
107
-
108
- Params:
109
-
110
- - **key** [String] This is the unique key of the item to remove from the cache store.
111
-
112
- Example:
113
-
114
- cache_store.remove('country_code')
115
-
116
-
117
- **#exist?**
118
-
119
- This method is called to check if a value has been stored in the cache store for a specific key.
120
-
121
- Params:
122
-
123
- **key** [String]
124
- This is the unique key of the value to check for.
125
-
126
- Example:
127
-
128
- if cache_store.exist?('country_code')
129
- ....do logic here
130
- end
131
-
132
-
133
- ##LocalCacheStore
134
-
135
- 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 reds or memcached etc as a distributed cache.
136
-
137
- #create a new instance of the cache store
138
- cache_store = LocalCacheStore.new
139
-
140
- > **CacheStore** works perfectly with **Sinject** a dependency injection framework allowing you to switch the cache store implementations used for different environments.
141
-
142
- ## Development
143
-
144
- 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.
145
-
146
- 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).
147
-
148
- ## Contributing
149
-
150
- Bug reports and pull requests are welcome on GitHub at https://github.com/vaughanbrittonsage/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.
151
-
152
-
153
- ## License
154
-
155
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
156
-