arunthampi-memcached 0.17.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.gitmodules +3 -0
- data/BENCHMARKS +120 -0
- data/CHANGELOG +58 -0
- data/LICENSE +184 -0
- data/Manifest +27 -0
- data/README +118 -0
- data/Rakefile +45 -0
- data/TODO +4 -0
- data/VERSION +1 -0
- data/ext/extconf.rb +106 -0
- data/ext/libmemcached-0.32.tar.gz +0 -0
- data/ext/libmemcached.patch +270 -0
- data/ext/rlibmemcached.i +212 -0
- data/ext/rlibmemcached_wrap.c +13090 -0
- data/lib/memcached.rb +31 -0
- data/lib/memcached/behaviors.rb +78 -0
- data/lib/memcached/exceptions.rb +84 -0
- data/lib/memcached/integer.rb +6 -0
- data/lib/memcached/memcached.rb +554 -0
- data/lib/memcached/rails.rb +97 -0
- data/test/profile/benchmark.rb +210 -0
- data/test/profile/profile.rb +14 -0
- data/test/profile/valgrind.rb +147 -0
- data/test/setup.rb +29 -0
- data/test/teardown.rb +0 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/binding_test.rb +8 -0
- data/test/unit/memcached_test.rb +1132 -0
- data/test/unit/rails_test.rb +102 -0
- metadata +94 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
require "#{File.dirname(__FILE__)}/../test_helper"
|
3
|
+
|
4
|
+
class RailsTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@servers = ['127.0.0.1:43042', '127.0.0.1:43043', "#{UNIX_SOCKET_NAME}0"]
|
8
|
+
@namespace = 'rails_test'
|
9
|
+
@cache = Memcached::Rails.new(:servers => @servers, :namespace => @namespace)
|
10
|
+
@value = OpenStruct.new(:a => 1, :b => 2, :c => GenericClass)
|
11
|
+
@marshalled_value = Marshal.dump(@value)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get
|
15
|
+
@cache.set key, @value
|
16
|
+
result = @cache.get key
|
17
|
+
assert_equal @value, result
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_get_multi
|
21
|
+
@cache.set key, @value
|
22
|
+
result = @cache.get_multi([key])
|
23
|
+
assert_equal(
|
24
|
+
{key => @value},
|
25
|
+
result
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_delete
|
30
|
+
@cache.set key, @value
|
31
|
+
assert_nothing_raised do
|
32
|
+
@cache.delete key
|
33
|
+
end
|
34
|
+
assert_nil(@cache.get(key))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_delete_missing
|
38
|
+
assert_nothing_raised do
|
39
|
+
@cache.delete key
|
40
|
+
assert_nil(@cache.delete(key))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_bracket_accessors
|
45
|
+
@cache[key] = @value
|
46
|
+
result = @cache[key]
|
47
|
+
assert_equal @value, result
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_cas
|
51
|
+
cache = Memcached::Rails.new(:servers => @servers, :namespace => @namespace, :support_cas => true)
|
52
|
+
value2 = OpenStruct.new(:d => 3, :e => 4, :f => GenericClass)
|
53
|
+
|
54
|
+
# Existing set
|
55
|
+
cache.set key, @value
|
56
|
+
cache.cas(key) do |current|
|
57
|
+
assert_equal @value, current
|
58
|
+
value2
|
59
|
+
end
|
60
|
+
assert_equal value2, cache.get(key)
|
61
|
+
|
62
|
+
# Missing set
|
63
|
+
cache.delete key
|
64
|
+
assert_nothing_raised do
|
65
|
+
cache.cas(key) { @called = true }
|
66
|
+
end
|
67
|
+
assert_nil cache.get(key)
|
68
|
+
assert_nil @called
|
69
|
+
|
70
|
+
# Conflicting set
|
71
|
+
cache.set key, @value
|
72
|
+
assert_raises(Memcached::ConnectionDataExists) do
|
73
|
+
cache.cas(key) do |current|
|
74
|
+
cache.set key, value2
|
75
|
+
current
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_get_missing
|
81
|
+
@cache.delete key rescue nil
|
82
|
+
result = @cache.get key
|
83
|
+
assert_equal nil, result
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_get_nil
|
87
|
+
@cache.set key, nil, 0
|
88
|
+
result = @cache.get key
|
89
|
+
assert_equal nil, result
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_namespace
|
93
|
+
assert_equal @namespace, @cache.namespace
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def key
|
99
|
+
caller.first[/.*[` ](.*)'/, 1] # '
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arunthampi-memcached
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.17.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chu Yeow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-11 00:00:00 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Chu Yeow's fork of memcached which allows big-set and big-get
|
17
|
+
email: chuyeow@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README
|
25
|
+
- TODO
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- .gitmodules
|
29
|
+
- BENCHMARKS
|
30
|
+
- CHANGELOG
|
31
|
+
- LICENSE
|
32
|
+
- Manifest
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- TODO
|
36
|
+
- VERSION
|
37
|
+
- ext/extconf.rb
|
38
|
+
- ext/libmemcached-0.32.tar.gz
|
39
|
+
- ext/libmemcached.patch
|
40
|
+
- ext/rlibmemcached.i
|
41
|
+
- ext/rlibmemcached_wrap.c
|
42
|
+
- lib/memcached.rb
|
43
|
+
- lib/memcached/behaviors.rb
|
44
|
+
- lib/memcached/exceptions.rb
|
45
|
+
- lib/memcached/integer.rb
|
46
|
+
- lib/memcached/memcached.rb
|
47
|
+
- lib/memcached/rails.rb
|
48
|
+
- test/profile/benchmark.rb
|
49
|
+
- test/profile/profile.rb
|
50
|
+
- test/profile/valgrind.rb
|
51
|
+
- test/setup.rb
|
52
|
+
- test/teardown.rb
|
53
|
+
- test/test_helper.rb
|
54
|
+
- test/unit/binding_test.rb
|
55
|
+
- test/unit/memcached_test.rb
|
56
|
+
- test/unit/rails_test.rb
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: http://github.com/chuyeow/memcached
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options:
|
63
|
+
- --charset=UTF-8
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Chu Yeow's fork of memcached which allows big-set and big-get
|
85
|
+
test_files:
|
86
|
+
- test/profile/benchmark.rb
|
87
|
+
- test/profile/profile.rb
|
88
|
+
- test/profile/valgrind.rb
|
89
|
+
- test/setup.rb
|
90
|
+
- test/teardown.rb
|
91
|
+
- test/test_helper.rb
|
92
|
+
- test/unit/binding_test.rb
|
93
|
+
- test/unit/memcached_test.rb
|
94
|
+
- test/unit/rails_test.rb
|