alephant-cache 1.2.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alephant/cache.rb +35 -10
- data/lib/alephant/cache/version.rb +1 -1
- 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: 9c6fec79289d06c6c4cb6ffdf70f44595a3323e6
|
4
|
+
data.tar.gz: 13a2d029f0f62f471ff68c0165fd5cffdf78f94d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addd116f260d7d4ab7e64046e0d8048b231e222bce199642a66c1f2a188925b5cec453fd5d529b571e0c2ed09a5cf526ae8d34ef1bef3c446d158e9333fa2ec1
|
7
|
+
data.tar.gz: b31b9e1971640ed2ec66d23ff00e207d435d1f25a30f396121e93f5b07cf415990b729752c89a32fad731bba6c6a44c93a79e60853ea3ce80de2d845b0e6e273
|
data/lib/alephant/cache.rb
CHANGED
@@ -10,14 +10,23 @@ module Alephant
|
|
10
10
|
def initialize(id, path)
|
11
11
|
@id = id
|
12
12
|
@path = path
|
13
|
-
|
14
13
|
@bucket = AWS::S3.new.buckets[id]
|
15
|
-
|
14
|
+
|
15
|
+
logger.info(
|
16
|
+
"event" => "CacheInitialized",
|
17
|
+
"id" => id,
|
18
|
+
"path" => path,
|
19
|
+
"method" => "#{self.class}#initialize",
|
20
|
+
)
|
16
21
|
end
|
17
22
|
|
18
23
|
def clear
|
19
24
|
bucket.objects.with_prefix(path).delete_all
|
20
|
-
logger.info(
|
25
|
+
logger.info(
|
26
|
+
"event" => "CacheCleared",
|
27
|
+
"path" => path,
|
28
|
+
"method" => "#{self.class}#clear"
|
29
|
+
)
|
21
30
|
end
|
22
31
|
|
23
32
|
def put(id, data, content_type = 'text/plain', meta = {})
|
@@ -30,20 +39,36 @@ module Alephant
|
|
30
39
|
)
|
31
40
|
|
32
41
|
logger.metric "CachePuts"
|
33
|
-
logger.info(
|
42
|
+
logger.info(
|
43
|
+
"event" => "CacheObjectStored",
|
44
|
+
"path" => path,
|
45
|
+
"id" => id,
|
46
|
+
"method" => "#{self.class}#put"
|
47
|
+
)
|
34
48
|
end
|
35
49
|
|
36
50
|
def get(id)
|
51
|
+
object = bucket.objects["#{path}/#{id}"]
|
52
|
+
content = object.read
|
53
|
+
content_type = object.content_type,
|
54
|
+
meta_data = object.metadata.to_h
|
55
|
+
|
37
56
|
logger.metric "CacheGets"
|
38
|
-
logger.info(
|
39
|
-
|
57
|
+
logger.info(
|
58
|
+
"event" => "CacheObjectRetrieved",
|
59
|
+
"path" => path,
|
60
|
+
"id" => id,
|
61
|
+
"content" => content,
|
62
|
+
"contentType" => content_type,
|
63
|
+
"metadata" => meta_data,
|
64
|
+
"method" => "#{self.class}#get"
|
65
|
+
)
|
40
66
|
|
41
67
|
{
|
42
|
-
:content =>
|
43
|
-
:content_type =>
|
44
|
-
:meta =>
|
68
|
+
:content => content,
|
69
|
+
:content_type => content_type,
|
70
|
+
:meta => meta_data
|
45
71
|
}
|
46
72
|
end
|
47
73
|
end
|
48
74
|
end
|
49
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BBC News
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|