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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6b38cf179ce0ee08cce1d24f0a9b500679473a1
4
- data.tar.gz: 88e6050d78b33d45ed7f39de037398a1b3207c69
3
+ metadata.gz: 9c6fec79289d06c6c4cb6ffdf70f44595a3323e6
4
+ data.tar.gz: 13a2d029f0f62f471ff68c0165fd5cffdf78f94d
5
5
  SHA512:
6
- metadata.gz: 4527c1b5bb2d03903840832ac0def8fd9417900f21605e6be6e732a030d223c552327eef6badcee7baa7b384c9df24a0bf21883cbd3ce44d38c4c63cfcf10707
7
- data.tar.gz: ced6da3e1fc389aba03a6e96c5ee41ffdd8a7f0e295112ebdb7f7c9f248079bc05ecb7b6c98b7c9afd14049750954eb63bfe696e5c024a85f4b310a43ef22a44
6
+ metadata.gz: addd116f260d7d4ab7e64046e0d8048b231e222bce199642a66c1f2a188925b5cec453fd5d529b571e0c2ed09a5cf526ae8d34ef1bef3c446d158e9333fa2ec1
7
+ data.tar.gz: b31b9e1971640ed2ec66d23ff00e207d435d1f25a30f396121e93f5b07cf415990b729752c89a32fad731bba6c6a44c93a79e60853ea3ce80de2d845b0e6e273
@@ -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
- logger.info("Cache.initialize: end with id #{id} and path #{path}")
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("Cache.clear: #{path}")
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("Cache.put: #{path}/#{id}")
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("Cache.get: #{path}/#{id}")
39
- object = bucket.objects["#{path}/#{id}"]
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 => object.read,
43
- :content_type => object.content_type,
44
- :meta => object.metadata.to_h
68
+ :content => content,
69
+ :content_type => content_type,
70
+ :meta => meta_data
45
71
  }
46
72
  end
47
73
  end
48
74
  end
49
-
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  class Cache
3
- VERSION = "1.2.4"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
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: 1.2.4
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-06-02 00:00:00.000000000 Z
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