stormpath-sdk 1.2.0 → 1.2.1
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 +4 -4
- data/CHANGES.md +8 -0
- data/lib/stormpath-sdk/cache/memcached_store.rb +14 -7
- data/lib/stormpath-sdk/data_store.rb +1 -0
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/data_store_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3691a66f261c76c712cf287ab23eb915c8fbc9b
|
4
|
+
data.tar.gz: 23271526986e5b0ca026d6010f213c76534b88bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a307a58bee08d85c5595e4d9889f2ff4d0dda416dc91f57c91edd7fa55655991805722a273064f0dad372c1d9cd4e073e436c9de1d41d7774e3737cbb50dd0
|
7
|
+
data.tar.gz: 7f0fe61d86c0d23a3f8c9c1888585b97a46f4494197121be2d0411e9476a3ccd398f53bc3d7b2bd45cba5bf44ce4596e0ac96b7662e08ea636042d7972d71f32
|
data/CHANGES.md
CHANGED
@@ -3,14 +3,17 @@ require 'memcached'
|
|
3
3
|
module Stormpath
|
4
4
|
module Cache
|
5
5
|
class MemcachedStore
|
6
|
+
DEFAULT_SERVER_HOST = 'localhost:11211'.freeze
|
7
|
+
attr_reader :memcached, :options
|
8
|
+
|
6
9
|
def initialize(opts = {})
|
7
|
-
options =
|
8
|
-
@memcached = Memcached.new(options)
|
10
|
+
@options = opts.blank? ? { host: DEFAULT_SERVER_HOST } : opts
|
11
|
+
@memcached = Memcached.new(options[:host], options_without_host)
|
9
12
|
end
|
10
13
|
|
11
14
|
def get(key)
|
12
15
|
begin
|
13
|
-
entry =
|
16
|
+
entry = memcached.get(key)
|
14
17
|
entry && Stormpath::Cache::CacheEntry.from_h(MultiJson.load(entry))
|
15
18
|
rescue Memcached::NotFound
|
16
19
|
nil
|
@@ -18,19 +21,23 @@ module Stormpath
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def put(key, entry)
|
21
|
-
|
24
|
+
memcached.set(key, MultiJson.dump(entry.to_h))
|
22
25
|
end
|
23
26
|
|
24
27
|
def delete(key)
|
25
|
-
|
28
|
+
memcached.delete(key)
|
26
29
|
end
|
27
30
|
|
28
31
|
def clear
|
29
|
-
|
32
|
+
memcached.flush
|
30
33
|
end
|
31
34
|
|
32
35
|
def size
|
33
|
-
|
36
|
+
memcached.stats[:curr_items]
|
37
|
+
end
|
38
|
+
|
39
|
+
def options_without_host
|
40
|
+
options.tap { |hs| hs.delete(:host) }
|
34
41
|
end
|
35
42
|
end
|
36
43
|
end
|
@@ -42,6 +42,7 @@ class Stormpath::DataStore
|
|
42
42
|
CACHE_REGIONS.each do |region|
|
43
43
|
region_opts = regions_opts[region.to_sym] || {}
|
44
44
|
region_opts[:store] ||= cache_opts[:store]
|
45
|
+
region_opts[:store_opts] ||= cache_opts[:store_opts]
|
45
46
|
@cache_manager.create_cache region, region_opts
|
46
47
|
end
|
47
48
|
end
|
data/spec/data_store_spec.rb
CHANGED
@@ -4,7 +4,7 @@ shared_examples 'a data store' do
|
|
4
4
|
let(:factory) { Stormpath::Test::ResourceFactory.new }
|
5
5
|
let(:request_executor) { Stormpath::Test::TestRequestExecutor.new }
|
6
6
|
let(:data_store) do
|
7
|
-
Stormpath::DataStore.new(request_executor, test_api_key,
|
7
|
+
Stormpath::DataStore.new(request_executor, test_api_key, store, nil)
|
8
8
|
end
|
9
9
|
let(:application_cache) { data_store.cache_manager.get_cache 'applications' }
|
10
10
|
let(:tenant_cache) { data_store.cache_manager.get_cache 'tenants' }
|
@@ -182,12 +182,12 @@ end
|
|
182
182
|
|
183
183
|
describe Stormpath::DataStore do
|
184
184
|
context 'redis store' do
|
185
|
-
let(:store) { Stormpath::Cache::RedisStore }
|
185
|
+
let(:store) { { store: Stormpath::Cache::RedisStore, store_opts: { read_timeout: 6.0 } } }
|
186
186
|
it_should_behave_like 'a data store'
|
187
187
|
end
|
188
188
|
|
189
189
|
context 'memcached store' do
|
190
|
-
let(:store) { Stormpath::Cache::MemcachedStore }
|
190
|
+
let(:store) { { store: Stormpath::Cache::MemcachedStore, store_opts: { host: 'localhost:11211', prefix_key: 'mem' } } }
|
191
191
|
it_should_behave_like 'a data store'
|
192
192
|
end
|
193
193
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stormpath-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stormpath, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|