aqila-cache 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: 16a8b082b146d8ffcbe3e0bb7a7171e50c4f53b2df0925cd7e142b00f97375e1
4
- data.tar.gz: c4b9708e3d4df367ca1d9d01f66515c5771b7111904f26544092c66d800b8822
3
+ metadata.gz: 13d178c65d3d062a0ef64fbd97157dc9bc3bc91efbf3726a5f3fce5ba7887c06
4
+ data.tar.gz: bb11f74c1e4ca565779cf82ca86acfa8f1649d143e62933532ddf402bf6362f2
5
5
  SHA512:
6
- metadata.gz: 1ff200b210df303b311790758e96e937d4731c6dab3cca853153093799d762ef6faca9aa45f8725ba8451dd2324d2065e8e6bfacc7c3bcefbd762988e204965d
7
- data.tar.gz: 18ad9b51c189ec2de78d1f9da72a8e112298c98dfc1a81253d8d686e72380bbadc8193ae571151eab7a2c58b3fcbd4efd97b3fe5105ea31e7a9f948b8431dd1b
6
+ metadata.gz: a88ac3a544a96e45952d4ef13820015bd2d6ae0b995779b0ef399cbd9c3578cb0d66a79f614df5c3ec9835bb0121d0094e9204e670c3c53765564a6e8eed6b50
7
+ data.tar.gz: 26f21db4437a5ff008541e4bbcf6c7db912094544ad58c9f94033a00cc993a1db1a39b4637c3f3ae1e5523a6db060d9861dd35e1b6bc7b7bd3d924102ebcf25e
data/README.md CHANGED
@@ -1,43 +1,39 @@
1
1
  # Aqila::Cache
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aqila/cache`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Invalidate the cache when the model data changes.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Publish
6
6
 
7
- ## Installation
7
+ `make release`
8
8
 
9
- Add this line to your application's Gemfile:
9
+ # Guide
10
10
 
11
- ```ruby
12
- gem 'aqila-cache'
11
+ Initializer:
12
+ ```
13
+ Aqila::Cache.configure do |config|
14
+ config.configure_model do |model|
15
+ model.table_name = :ino_log_table
16
+ model.sequence_name = :gen_ino_log_table
17
+ end
18
+ config.default_ttl = 1.day
19
+ end
13
20
  ```
14
21
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install aqila-cache
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aqila-cache. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
- ## License
22
+ Example Model:
38
23
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
24
+ ```
25
+ class Estadio < ActiveRecord::Base
26
+ include Aqila::Cache::Callbacks
40
27
 
41
- ## Code of Conduct
28
+ self.cache_ttl = 1.day
29
+ ...
30
+ end
31
+ ```
42
32
 
43
- Everyone interacting in the Aqila::Cache project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/aqila-cache/blob/master/CODE_OF_CONDUCT.md).
33
+ Example Controller:
34
+ ```
35
+ class V1::EstadiosController < ApplicationController
36
+ def index
37
+ return unless Estadio.stale?(controller: self)
38
+ ...
39
+ ```
@@ -7,8 +7,14 @@ module Aqila
7
7
  module Cache
8
8
  class Error < StandardError; end
9
9
 
10
- def self.configure_model
11
- yield(Aqila::Cache::TableLastChange)
10
+ require 'aqila/cache/configuration'
11
+
12
+ def self.configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def self.configure
17
+ yield(configuration)
12
18
  end
13
19
 
14
20
  require 'aqila/cache/table_last_change'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aqila
4
+ module Cache
5
+ class Configuration
6
+ attr_accessor :default_ttl
7
+
8
+ def configure_model
9
+ yield(Aqila::Cache::TableLastChange)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -11,7 +11,7 @@ module Aqila
11
11
  end
12
12
 
13
13
  def self.cache_ttl
14
- @cache_ttl
14
+ @cache_ttl || Aqila::Cache.configuration.default_ttl
15
15
  end
16
16
 
17
17
  def self.update_log_table
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aqila
4
4
  module Cache
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aqila-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agro1 Desenvolvimento
@@ -175,6 +175,7 @@ files:
175
175
  - db/schema.rb
176
176
  - lib/aqila/cache.rb
177
177
  - lib/aqila/cache/callbacks.rb
178
+ - lib/aqila/cache/configuration.rb
178
179
  - lib/aqila/cache/methods.rb
179
180
  - lib/aqila/cache/table_last_change.rb
180
181
  - lib/aqila/cache/version.rb