shrine-redis 0.0.1 → 1.0.0
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/README.md +9 -10
- data/lib/shrine/storage/{redis_storage.rb → redis.rb} +17 -9
- data/shrine-redis.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc1cb0365ddc045d3c7ba11dfe04f502618957fc
|
4
|
+
data.tar.gz: 03b1815f9d171340c8c155cfedd9cd64f701194f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c64b4918bf513e3145953aae1509413a9cb996d8bf1b54d5c6c014c57a3ec5a9d4c8fab095767ec3ed8b5ccf8555fde09b6763c0a3551675035f12427f5e7a
|
7
|
+
data.tar.gz: 9a4bc6bf562bafe15815fc1f4f2a4bea9dc20368f716aec50444ec4debd53191bef46fdde7c525bae50bc24f7bb4af4de381ba026ccdbd87d87a0fa8d60ac6fb
|
data/README.md
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
# Shrine::Storage::
|
1
|
+
# Shrine::Storage::Redis
|
2
2
|
|
3
3
|
Provides a Shrine Storage for storing files in Redis.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
gem
|
8
|
+
gem "shrine-redis"
|
9
9
|
```
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
13
|
```rb
|
14
|
-
require "shrine/storage/
|
15
|
-
require "redis"
|
14
|
+
require "shrine/storage/redis"
|
16
15
|
|
17
16
|
redis = Redis.new(url: "redis://host:port/db")
|
18
17
|
|
19
18
|
Shrine.storages = {
|
20
|
-
cache: Shrine::Storage::
|
21
|
-
redis,
|
22
|
-
prefix:
|
19
|
+
cache: Shrine::Storage::Redis.new(
|
20
|
+
client: redis,
|
21
|
+
prefix: "cache",
|
23
22
|
expire: 60
|
24
23
|
),
|
25
|
-
store: Shrine::Storage::
|
26
|
-
redis,
|
27
|
-
prefix:
|
24
|
+
store: Shrine::Storage::Redis.new(
|
25
|
+
client: redis,
|
26
|
+
prefix: "store",
|
28
27
|
expire: 3600
|
29
28
|
)
|
30
29
|
}
|
@@ -5,14 +5,14 @@ require "stringio"
|
|
5
5
|
|
6
6
|
class Shrine
|
7
7
|
module Storage
|
8
|
-
class
|
8
|
+
class Redis
|
9
9
|
attr_reader :redis, :prefix, :expire
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@redis =
|
11
|
+
def initialize(client: nil, prefix: nil, expire: nil, **options)
|
12
|
+
@redis = client || ::Redis.new(options)
|
13
13
|
@prefix = prefix
|
14
14
|
@expire = expire
|
15
|
-
raise ArgumentError, 'Missing redis client' unless redis
|
15
|
+
raise ArgumentError, 'Missing redis client' unless @redis.is_a?(::Redis)
|
16
16
|
end
|
17
17
|
|
18
18
|
def upload(io, id, shrine_metadata: {}, **upload_options)
|
@@ -39,18 +39,26 @@ class Shrine
|
|
39
39
|
redis.del(key(id))
|
40
40
|
end
|
41
41
|
|
42
|
+
def multi_delete(ids)
|
43
|
+
if ids.is_a?(Array)
|
44
|
+
ids.each { |id| delete(id) }
|
45
|
+
elsif ids.is_a?(String)
|
46
|
+
redis.del(keys(ids))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
private
|
43
51
|
|
44
52
|
def content(id)
|
45
53
|
redis.get(key(id)).to_s
|
46
54
|
end
|
47
55
|
|
56
|
+
def keys(id)
|
57
|
+
redis.keys(key(id))
|
58
|
+
end
|
59
|
+
|
48
60
|
def key(id)
|
49
|
-
|
50
|
-
"#{prefix}:#{id}"
|
51
|
-
else
|
52
|
-
"#{id}"
|
53
|
-
end
|
61
|
+
[*prefix, id].join(":")
|
54
62
|
end
|
55
63
|
end
|
56
64
|
end
|
data/shrine-redis.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Crowther
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
@@ -89,7 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- LICENSE.txt
|
91
91
|
- README.md
|
92
|
-
- lib/shrine/storage/
|
92
|
+
- lib/shrine/storage/redis.rb
|
93
93
|
- shrine-redis.gemspec
|
94
94
|
homepage: https://github.com/dbongo/shrine-redis
|
95
95
|
licenses:
|