cachext 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 99eccddb9064b17d7043869d9f62d2a39438cd12
4
- data.tar.gz: 9cd79f5b34f472c9c855b981cab782e4af3f6086
3
+ metadata.gz: c57e65ad4f06f5acff5ddc4d5b3554fb9bd49ec5
4
+ data.tar.gz: 964fed39f446dda576f5505a8489254718507a50
5
5
  SHA512:
6
- metadata.gz: db58512dcee683c1b3a3ea996eb0505f57020e1b81ae8c73e933f10fc9956670fae3cd7d09293063eeeca043305c6a31c800ab4861078265afcb8477866985b7
7
- data.tar.gz: 31204397cfda1149f6d77e08a75392359c244a2399a1a7bb8ea0468998b27ebac4e6a13eae8a988621534d95a534596abf29c3a99d4af89377aa20b91b2f7408
6
+ metadata.gz: 9a3e5777bcb4d6c4f0183e10c3738416f807ad8edb7102ba4fb4a08da3a340bf2f3e229bb113aaea4d310b751f68d01e6a6bdee2543e7cee7089322cfc6344fb
7
+ data.tar.gz: 8f4d957745f93daf3e20a6abf7dd5f3b1283a7d3a906410b97e64011a1aec0fcda2cf3153f202d3316d383296f51c50e78deee5686744e458668fc009af802f3
data/.travis.yml CHANGED
@@ -2,3 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
4
  before_install: gem install bundler -v 1.10.6
5
+ services:
6
+ - memcache
7
+ - redis
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Cachext
2
2
 
3
+ [![Build Status](https://travis-ci.org/dplummer/cachext.svg)](https://travis-ci.org/dplummer/cachext)
4
+ [![Gem Version](https://badge.fury.io/rb/cachext.svg)](https://badge.fury.io/rb/cachext)
5
+
3
6
  Extensions to normal Rails caching:
4
7
 
5
8
  * Lock (inspired by https://github.com/seamusabshere/lock_and_cache)
@@ -8,8 +11,10 @@ Extensions to normal Rails caching:
8
11
  ## Quickstart
9
12
 
10
13
  ```ruby
11
- Cachext.config.cache = Rails.cache
12
- Cachext.config.redis = Redis.current
14
+ Cachext.configure do |config|
15
+ config.cache = Rails.cache
16
+ config.redis = Redis.current
17
+ end
13
18
 
14
19
  key = [:foo, :bar, 1]
15
20
  Cachext.fetch key, expires_in: 2.hours, default: "cow" do
data/lib/cachext.rb CHANGED
@@ -30,6 +30,10 @@ module Cachext
30
30
  @client ||= Client.new config
31
31
  end
32
32
 
33
+ def self.config=(new_config)
34
+ @config = new_config
35
+ end
36
+
33
37
  def self.config
34
38
  @config ||= Configuration.new
35
39
  end
@@ -42,4 +46,8 @@ module Cachext
42
46
  def self.multi klass, ids, options = {}, &block
43
47
  Multi.new(config, klass, options).fetch ids, &block
44
48
  end
49
+
50
+ def self.configure &block
51
+ @config = Configuration.setup(&block)
52
+ end
45
53
  end
@@ -14,6 +14,25 @@ module Cachext
14
14
  :debug, # output debug messages to STDERR
15
15
  :heartbeat_expires # time in seconds for process heardbeat to expire
16
16
 
17
+ MissingConfiguration = Class.new(StandardError)
18
+
19
+ def self.setup
20
+ config = new
21
+ yield config
22
+
23
+ if config.cache.nil?
24
+ raise MissingConfiguration, "Must configure the config.cache. Try config.cache = Rails.cache"
25
+ end
26
+
27
+ if config.redis.nil?
28
+ raise MissingConfiguration, "Must configure the config.redis. Try config.redis = Redis.current"
29
+ end
30
+
31
+ config.lock_manager
32
+
33
+ config
34
+ end
35
+
17
36
  def initialize
18
37
  self.raise_errors = false
19
38
  self.default_errors = [
@@ -1,3 +1,3 @@
1
1
  module Cachext
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cachext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Plummer