iron_cache 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +8 -8
- data/README.md +5 -5
- data/iron_cache.gemspec +1 -1
- data/lib/iron_cache/client.rb +20 -16
- data/lib/iron_cache/items.rb +2 -2
- data/lib/iron_cache/version.rb +1 -1
- data/lib/iron_cache.rb +1 -0
- data/test/test_base.rb +9 -0
- data/test/test_iron_cache.rb +8 -3
- data/test/test_memcached.rb +6 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
iron_cache (
|
5
|
-
iron_core (>= 0.
|
4
|
+
iron_cache (1.0.0)
|
5
|
+
iron_core (>= 0.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ffi (1.0.11)
|
11
|
-
iron_core (0.
|
12
|
-
|
13
|
-
rest
|
14
|
-
rest-client
|
11
|
+
iron_core (0.2.0)
|
12
|
+
rest (>= 2.0.0)
|
15
13
|
memcache-client (1.8.5)
|
16
14
|
mime-types (1.19)
|
15
|
+
net-http-persistent (2.7)
|
17
16
|
rake (0.9.2.2)
|
18
|
-
rest (
|
17
|
+
rest (2.0.0)
|
18
|
+
net-http-persistent
|
19
19
|
rest-client (>= 0.3.0)
|
20
20
|
rest-client (1.6.7)
|
21
21
|
mime-types (>= 1.16)
|
22
|
-
test-unit (2.5.
|
22
|
+
test-unit (2.5.1)
|
23
23
|
typhoeus (0.4.2)
|
24
24
|
ffi (~> 1.0)
|
25
25
|
mime-types (~> 1.18)
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Getting Started
|
|
17
17
|
The Basics
|
18
18
|
=========
|
19
19
|
|
20
|
-
**Get a
|
20
|
+
**Get a Cache object**
|
21
21
|
|
22
22
|
You can have as many caches as you want, each with their own unique set of items.
|
23
23
|
|
@@ -27,13 +27,13 @@ Now you can use it:
|
|
27
27
|
|
28
28
|
**Put** an item in the cache:
|
29
29
|
|
30
|
-
|
31
|
-
p
|
30
|
+
item = @cache.put("mykey", "hello world!")
|
31
|
+
p item
|
32
32
|
|
33
33
|
**Get** an item from the cache:
|
34
34
|
|
35
|
-
|
36
|
-
p
|
35
|
+
item = @cache.get("mykey")
|
36
|
+
p item.value
|
37
37
|
|
38
38
|
**Delete** an item from the cache:
|
39
39
|
|
data/iron_cache.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
|
17
17
|
gem.required_rubygems_version = ">= 1.3.6"
|
18
18
|
gem.required_ruby_version = Gem::Requirement.new(">= 1.9")
|
19
|
-
gem.add_runtime_dependency "iron_core", ">= 0.
|
19
|
+
gem.add_runtime_dependency "iron_core", ">= 0.2.0"
|
20
20
|
|
21
21
|
gem.add_development_dependency "test-unit"
|
22
22
|
gem.add_development_dependency "rake"
|
data/lib/iron_cache/client.rb
CHANGED
@@ -9,29 +9,34 @@ module IronCache
|
|
9
9
|
|
10
10
|
AWS_US_EAST_HOST = "cache-aws-us-east-1.iron.io"
|
11
11
|
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :logger
|
13
13
|
|
14
14
|
def initialize(options={})
|
15
|
-
|
15
|
+
default_options = {
|
16
|
+
:scheme => 'https',
|
17
|
+
:host => IronCache::Client::AWS_US_EAST_HOST,
|
18
|
+
:port => 443,
|
19
|
+
:api_version => 1,
|
20
|
+
:user_agent => 'iron_mq_ruby-' + IronCache::VERSION + ' (iron_core_ruby-' + IronCore.version + ')',
|
21
|
+
:cache_name => 'default'
|
22
|
+
}
|
16
23
|
|
17
|
-
|
18
|
-
@logger.level = Logger::INFO
|
24
|
+
super('iron', 'cache', options, default_options, [:project_id, :token, :api_version, :cache_name])
|
19
25
|
|
20
|
-
|
26
|
+
IronCore::Logger.error 'IronCache', "Token is not set", IronCore::Error if @token.nil?
|
21
27
|
|
22
|
-
|
23
|
-
:scheme => 'https',
|
24
|
-
:host => AWS_US_EAST_HOST,
|
25
|
-
:port => 443,
|
26
|
-
:api_version => 1,
|
27
|
-
:user_agent => 'iron_cache_ruby-' + IronCache::VERSION + ' (iron_core_ruby-' + IronCore.version + ')'})
|
28
|
+
check_id(@project_id, 'project_id')
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
30
|
+
@logger = Logger.new(STDOUT)
|
31
|
+
@logger.level = Logger::INFO
|
32
|
+
end
|
33
33
|
|
34
|
+
def headers
|
35
|
+
super.merge({'Authorization' => "OAuth #{@token}"})
|
36
|
+
end
|
34
37
|
|
38
|
+
def url
|
39
|
+
super + @api_version.to_s + '/'
|
35
40
|
end
|
36
41
|
|
37
42
|
def items
|
@@ -45,7 +50,6 @@ module IronCache
|
|
45
50
|
def caches
|
46
51
|
return Caches.new(self)
|
47
52
|
end
|
48
|
-
|
49
53
|
end
|
50
54
|
|
51
55
|
class Error < StandardError
|
data/lib/iron_cache/items.rb
CHANGED
@@ -22,7 +22,7 @@ module IronCache
|
|
22
22
|
@client.logger.debug "GET response: " + res.inspect
|
23
23
|
json = @client.parse_response(res, true)
|
24
24
|
return Item.new(self, json)
|
25
|
-
rescue
|
25
|
+
rescue Rest::HttpError => ex
|
26
26
|
@client.logger.debug ex.inspect
|
27
27
|
if ex.code == 404
|
28
28
|
return nil
|
@@ -108,4 +108,4 @@ module IronCache
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
end
|
111
|
+
end
|
data/lib/iron_cache/version.rb
CHANGED
data/lib/iron_cache.rb
CHANGED
data/test/test_base.rb
CHANGED
@@ -33,4 +33,13 @@ class TestBase < Test::Unit::TestCase
|
|
33
33
|
#puts 'cleared.'
|
34
34
|
end
|
35
35
|
|
36
|
+
def assert_performance(time)
|
37
|
+
start_time = Time.now
|
38
|
+
yield
|
39
|
+
execution_time = Time.now - start_time
|
40
|
+
assert execution_time < time, "Execution time too big #{execution_time.round(2)}, should be #{time}"
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
36
45
|
end
|
data/test/test_iron_cache.rb
CHANGED
@@ -10,13 +10,18 @@ class IronCacheTests < TestBase
|
|
10
10
|
end
|
11
11
|
def test_performance_put_message
|
12
12
|
@client.cache_name = 'test_basics'
|
13
|
-
|
13
|
+
assert_performance 0.02 do
|
14
|
+
@client.items.put("key", "value")
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
def test_performance_put_100_messages
|
17
19
|
@client.cache_name = 'test_basics'
|
18
|
-
|
19
|
-
|
20
|
+
assert_performance 2 do
|
21
|
+
100.times do
|
22
|
+
res = @client.items.put("key", "value")
|
23
|
+
puts "putting message #{res.inspect}"
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
data/test/test_memcached.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iron_core
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: test-unit
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|