shark-on-lambda 2.0.0.rc1 → 2.0.0.rc2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 642998e593034c083639724031920edfe7568de50d276cc3c58932c099d94a0e
4
- data.tar.gz: 8101e725e3ef4f710422625726f87c7a324e986b9eb6184a988e0fdd3812bdda
3
+ metadata.gz: 2de1dc4c59a25047859c9c41c4a6216aa70480ef9b00f38ebfe47038c57f93bc
4
+ data.tar.gz: 61c7045d5ebb7830ba72371083345d62d9c3c36fed81ebfe8ac37697e1e06558
5
5
  SHA512:
6
- metadata.gz: d23eac59ce2797aac609444509d571a54ffb22024f11070a54dd43d600ceeeb2b527e421c1c9463ac08cceb4fa2b9ad6a366e496cebb47c2873276e9abf4a9ec
7
- data.tar.gz: 8932eeb3134b88fb0da09b35a3a70eb1b4d1bfb5b2a1f522b9f4bc23c07890b4c6c9cd061374aebf4eb80c09695ef69420da95cc7f608c415b81692724f41e56
6
+ metadata.gz: 3419eb783ba62c32a55809b52394d6ee9a1f5de0968f0b0b28e4d9877fbd48edba5012c872aeb3330dae8c3fa7fc6903fcdc31d75dfc987ce541f3c01b559818
7
+ data.tar.gz: 2715b4f010e87b4aeb9f330e58aa1564d8448b2962a2a94b70a5dce775e0d10901bf2dd218fa983ce5d24dcfaee4e18b14a417cdf20bbdc560396c5c0f5123bd
@@ -9,6 +9,8 @@
9
9
  - [Break] `SharkOnLambda::JsonapiController` was removed.
10
10
  - [Break] Support for `path_parameters` in RSpec helpers was removed.
11
11
  - [Break] Configuration files are not loaded automatically anymore.
12
+ - Added `SharkOnLambda::Cacheable`.
13
+ - Added `SharkOnLambda.cache` and `SharkOnLambda.global_cache`.
12
14
  - Added support for routing.
13
15
  - Use `rack-on-lambda` as an adapter for events from the (REST API flavoured) API Gateway.
14
16
 
@@ -38,7 +38,7 @@ module SharkOnLambda
38
38
  class << self
39
39
  extend Forwardable
40
40
 
41
- attr_writer :application, :env, :logger
41
+ attr_writer :application, :cache, :env, :global_cache, :logger
42
42
 
43
43
  def_instance_delegators :application, :initialize!, :root
44
44
 
@@ -50,10 +50,18 @@ module SharkOnLambda
50
50
  application.config
51
51
  end
52
52
 
53
+ def cache
54
+ @cache ||= ActiveSupport::Cache::NullStore.new
55
+ end
56
+
53
57
  def env
54
58
  @env || ENV['STAGE'].presence || 'development'
55
59
  end
56
60
 
61
+ def global_cache
62
+ @global_cache ||= ActiveSupport::Cache::NullStore.new
63
+ end
64
+
57
65
  def logger
58
66
  @logger ||= Logger.new($stdout)
59
67
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SharkOnLambda
4
+ module Cacheable
5
+ delegate :cache, :global_cache, to: SharkOnLambda
6
+
7
+ def cache_duration(item)
8
+ cache_durations[item] || cache_durations[:default]
9
+ end
10
+
11
+ private
12
+
13
+ def cache_durations
14
+ return @cache_durations if defined?(@cache_durations)
15
+
16
+ settings = SharkOnLambda.application.config_for(:settings) || {}
17
+ @cache_durations = settings.fetch(:cache_durations, {})
18
+ @cache_durations = @cache_durations.with_indifferent_access
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SharkOnLambda
4
- VERSION = '2.0.0.rc1'
4
+ VERSION = '2.0.0.rc2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shark-on-lambda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huy Dinh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -267,6 +267,7 @@ files:
267
267
  - lib/shark_on_lambda/api_gateway_handler.rb
268
268
  - lib/shark_on_lambda/application.rb
269
269
  - lib/shark_on_lambda/base_controller.rb
270
+ - lib/shark_on_lambda/cacheable.rb
270
271
  - lib/shark_on_lambda/configuration.rb
271
272
  - lib/shark_on_lambda/errors/base.rb
272
273
  - lib/shark_on_lambda/errors/base_serializer.rb