async_cache 0.0.2 → 1.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: d672798f9a1aac8ba14134c46379e28dd0eb1de4
4
- data.tar.gz: c590ed218b9717d22a02e5e4583f8210e38ea9ed
3
+ metadata.gz: 6ebb087efa77e51ac632b1fdb6e5bc646c8fc924
4
+ data.tar.gz: 87c132d6f30e941a877bf2c5b221a2ab657e7aa9
5
5
  SHA512:
6
- metadata.gz: aaf71d240d334648fc1816fa060ca35eb9b497fc02e03b81c59666f22668feb6dbfdcb680263e2ad4a41fda4ed0d8933612e3a946d7756cb1443753158f228e8
7
- data.tar.gz: 28bb134215e14a0fe25723ab0ecee482db0eb5147bcdc301e8e3e63356daaa854710f00ade60a08c0c244d206bd3a1e22ac6c98cc155c3c16de8c2dc2260e2aa
6
+ metadata.gz: 3249570fd6634cca700cb69a4de34c2f4a9966df8db958ac4d701da432ae8b51e81730fd26b91d5a8e2e557bcf3d8c5a47f5bba815617675564dee07cdfcc506
7
+ data.tar.gz: 1b00cf6f828c2d61497979df32cff4e4f76853e9bb13b2765a6dbb84dcecdd9c267394a8888950790a5a505007b9de64452974a5fcac6332ab9d40f92b6168de
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  .DS_Store
2
+ pkg
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- async_cache (0.0.2)
4
+ async_cache (1.0.0)
5
5
  sourcify (~> 0.5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -15,25 +15,32 @@ gem 'async_cache'
15
15
  Then set up a store and fetch from it:
16
16
 
17
17
  ```ruby
18
- # Storing entries in `Rails.cache` and enqueueing via ActiveJob
19
- # (a Sidekiq worker is also available with additional
20
- # deduplication features).
21
- async_cache = AsyncCache::Store.new(
18
+ # (in config/initializers/async_cache.rb)
19
+ ASYNC_CACHE = AsyncCache::Store.new(
22
20
  backend: Rails.cache,
23
21
  worker: :active_job
24
22
  )
25
23
 
26
- # Then use it to do some heavy lifting asychronously
27
- id = params[:id]
28
- key = "big_model/#{id}"
29
- version = BigModel.where(:id => id).pluck(:updated_at).first
24
+ # (in app/controllers/things_controller.rb)
25
+ def show
26
+ # Then use it to do some heavy lifting asychronously
27
+ id = params[:id]
28
+ key = "thing/#{id}"
29
+ version = Thing.select(:updated_at).find(id).updated_at
30
30
 
31
- async_cache.fetch(key, version, arguments: [id]) do |id|
32
- BigModel.find(id).to_json
31
+ json = ASYNC_CACHE.fetch(key, version, arguments: [id]) do |id|
32
+ Thing.find(id).to_json
33
+ end
34
+
35
+ render body: json, content_type: 'application/json'
33
36
  end
34
37
  ```
35
38
 
36
- For additional examples see the [`examples`](examples/) folder.
39
+ For additional examples see the [`examples`](examples/) directory.
40
+
41
+ #### Workers
42
+
43
+ Async-cache provides a generic [ActiveJob](https://github.com/rails/rails/tree/master/activejob) worker as well as a specialized [Sidekiq](https://github.com/mperham/sidekiq) worker (see the [`workers`](lib/async_cache/workers/) directory). The ActiveJob worker should work out of the box is most cases. The Sidekiq worker provides special deduplication functionality which should significantly reduce the queue size/worker process load for high-traffic sites.
37
44
 
38
45
  ## Strategy
39
46
 
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ # No-op to make Travis CI happy
4
+ task 'default'
@@ -1,3 +1,3 @@
1
1
  module AsyncCache
2
- VERSION = '0.0.2'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Derewecki
@@ -66,6 +66,7 @@ files:
66
66
  - Gemfile.lock
67
67
  - LICENSE
68
68
  - README.md
69
+ - Rakefile
69
70
  - async_cache.gemspec
70
71
  - examples/examples_controller.rb
71
72
  - lib/async_cache.rb