sliced_redis 0.0.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.
- data/Gemfile +4 -0
- data/Gemfile.lock +44 -0
- data/Guardfile +11 -0
- data/README.md +5 -0
- data/Rakefile +9 -0
- data/lib/sliced_redis.rb +27 -0
- data/lib/sliced_redis/version.rb +3 -0
- data/sliced_redis.gemspec +25 -0
- data/spec/lib/sliced_redis_spec.rb +40 -0
- data/spec/spec_helper.rb +3 -0
- metadata +122 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sliced_redis (0.0.1)
|
5
|
+
redis
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.3)
|
11
|
+
ffi (1.1.5)
|
12
|
+
guard (1.3.2)
|
13
|
+
listen (>= 0.4.2)
|
14
|
+
thor (>= 0.14.6)
|
15
|
+
guard-rspec (1.2.1)
|
16
|
+
guard (>= 1.1)
|
17
|
+
listen (0.4.7)
|
18
|
+
rb-fchange (~> 0.0.5)
|
19
|
+
rb-fsevent (~> 0.9.1)
|
20
|
+
rb-inotify (~> 0.8.8)
|
21
|
+
rb-fchange (0.0.5)
|
22
|
+
ffi
|
23
|
+
rb-fsevent (0.9.1)
|
24
|
+
rb-inotify (0.8.8)
|
25
|
+
ffi (>= 0.5.0)
|
26
|
+
redis (3.0.1)
|
27
|
+
rspec (2.11.0)
|
28
|
+
rspec-core (~> 2.11.0)
|
29
|
+
rspec-expectations (~> 2.11.0)
|
30
|
+
rspec-mocks (~> 2.11.0)
|
31
|
+
rspec-core (2.11.1)
|
32
|
+
rspec-expectations (2.11.2)
|
33
|
+
diff-lcs (~> 1.1.3)
|
34
|
+
rspec-mocks (2.11.2)
|
35
|
+
thor (0.16.0)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
guard
|
42
|
+
guard-rspec
|
43
|
+
rspec
|
44
|
+
sliced_redis!
|
data/Guardfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
group :test do
|
2
|
+
gem 'guard-rspec'
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2 do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch('lib/sliced_redis.rb') { "spec" }
|
7
|
+
watch(%r{^lib/sliced_redis/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
8
|
+
watch('spec/spec_helper.rb') { "spec" }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
data/README.md
ADDED
data/Rakefile
ADDED
data/lib/sliced_redis.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "sliced_redis/version"
|
2
|
+
|
3
|
+
class SlicedRedis
|
4
|
+
class << self
|
5
|
+
def set( redis, key, value )
|
6
|
+
redis.multi do
|
7
|
+
redis.del key
|
8
|
+
chunked_append redis, key, value
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def setex( redis, key, expiration, value )
|
13
|
+
redis.multi do
|
14
|
+
redis.del key
|
15
|
+
chunked_append redis, key, value
|
16
|
+
redis.expire key, expiration
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Append value to the given key in 50kb chunks.
|
21
|
+
def chunked_append( redis, key, value )
|
22
|
+
value.scan( /.{1,51200}/ ) do |chunk|
|
23
|
+
redis.append key, chunk
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sliced_redis/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sliced_redis"
|
7
|
+
s.version = SlicedRedis::VERSION
|
8
|
+
s.authors = ["Tyson Tate"]
|
9
|
+
s.email = ["tyson@tysontate.com"]
|
10
|
+
s.homepage = "http://github.com/tysontate/sliced_redis"
|
11
|
+
s.summary = "Slice and dice Redis SET commands."
|
12
|
+
s.description = "Cut up large Redis SET commands into smaller pieces."
|
13
|
+
|
14
|
+
s.rubyforge_project = "sliced_redis"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
s.add_development_dependency "guard"
|
23
|
+
s.add_development_dependency "guard-rspec"
|
24
|
+
s.add_runtime_dependency "redis"
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe SlicedRedis do
|
4
|
+
let( :redis ) { Redis.new }
|
5
|
+
let( :key ) { "test" }
|
6
|
+
let( :small_value ) { "foo" }
|
7
|
+
let( :large_value ) { "x" * 1024 * 1024 }
|
8
|
+
|
9
|
+
after :each do
|
10
|
+
redis.del key
|
11
|
+
end
|
12
|
+
|
13
|
+
it "handles small set" do
|
14
|
+
SlicedRedis.set( redis, key, small_value )
|
15
|
+
redis.get( key ).should == small_value
|
16
|
+
end
|
17
|
+
|
18
|
+
it "handles large set" do
|
19
|
+
SlicedRedis.set( redis, key, large_value )
|
20
|
+
redis.get( key ).should == large_value
|
21
|
+
end
|
22
|
+
|
23
|
+
it "doesn't append to old value" do
|
24
|
+
2.times { SlicedRedis.set( redis, key, small_value ) }
|
25
|
+
redis.get( key ).should == small_value
|
26
|
+
end
|
27
|
+
|
28
|
+
it "handles small setex" do
|
29
|
+
SlicedRedis.setex( redis, key, 10, small_value )
|
30
|
+
redis.get( key ).should == small_value
|
31
|
+
redis.ttl( key ).should == 10
|
32
|
+
end
|
33
|
+
|
34
|
+
it "handles large setex" do
|
35
|
+
SlicedRedis.setex( redis, key, 10, large_value )
|
36
|
+
redis.get( key ).should == large_value
|
37
|
+
redis.ttl( key ).should == 10
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sliced_redis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tyson Tate
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: redis
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Cut up large Redis SET commands into smaller pieces.
|
79
|
+
email:
|
80
|
+
- tyson@tysontate.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- Gemfile
|
86
|
+
- Gemfile.lock
|
87
|
+
- Guardfile
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- lib/sliced_redis.rb
|
91
|
+
- lib/sliced_redis/version.rb
|
92
|
+
- sliced_redis.gemspec
|
93
|
+
- spec/lib/sliced_redis_spec.rb
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
homepage: http://github.com/tysontate/sliced_redis
|
96
|
+
licenses: []
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project: sliced_redis
|
115
|
+
rubygems_version: 1.8.23
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: Slice and dice Redis SET commands.
|
119
|
+
test_files:
|
120
|
+
- spec/lib/sliced_redis_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
has_rdoc:
|