cached_singleton 0.0.1 → 0.0.2
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 +14 -6
- data/README.md +10 -3
- data/lib/cached_singleton/cached_singleton.rb +3 -2
- data/lib/cached_singleton/version.rb +2 -2
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTYxMWFjZWIyOTk5ODhkODI0ZTMzYmEzMzQwNTU5OWI1ZTdhYjJkOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTEyYmRiNWM1ODJhZjdjN2FhN2UyYzQwYjAwYzdmNWE1ZjY2NTcyNA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjU0YWI2ZjNjYTU5MjA4MTlhNGExNGQyY2ZiNDg4NTYxNWNmODI4YTAwYWJj
|
10
|
+
YjUzZTFkOWM1NGIxMDJhZDlhOWM3YTZkOTg2MzNmODVhMDA2YjA5NTYxN2Fh
|
11
|
+
MDRkMDdhOWM4MzUyN2ZjYmM1NGY2MzZkNzdmZGVlYTUwNGRlMDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YmQ0ZGM3ZmFkNzY1MjlmZDMzMGJmOWYxZWZjZmYxNTU4NWFhYzFmNTM5NWNl
|
14
|
+
ZjY1NjNkMDUyNTdjOTY5NGNkZmJiMzcxMWRiYjRmNDc5YmMxZmE4MGRkMWFh
|
15
|
+
NGVhYzNhYjM5ZjE4ZGQ3NGNiYjllODZmZjQ2Mzc0MDI1YmY2MTk=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Cached::Singleton
|
2
2
|
|
3
|
-
|
3
|
+
CachedSingleton makes a single instance ActiveRecord object behave fully like a singleton.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,14 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
### Rails 3 apps
|
22
|
+
|
23
|
+
1. Create an initializer defining your cache strategy (by default we recommend):
|
24
|
+
```ruby
|
25
|
+
CachedSingleton.default_cache_strategy = Rails.cache
|
26
|
+
```
|
27
|
+
2. Include the module CachedSingleton in the ActiveModels you want to become singletons
|
28
|
+
3. Done!
|
22
29
|
|
23
30
|
## Contributing
|
24
31
|
|
@@ -26,4 +33,4 @@ TODO: Write usage instructions here
|
|
26
33
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
34
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
35
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
36
|
+
5. Create new Pull Request
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'cached_singleton/version'
|
2
2
|
|
3
3
|
module CachedSingleton
|
4
4
|
@@cache_strategy = nil
|
@@ -33,7 +33,8 @@ module CachedSingleton
|
|
33
33
|
|
34
34
|
# Get it in from the DB or create it
|
35
35
|
transaction do
|
36
|
-
# We ensure no other process is trying to SELECT
|
36
|
+
# We ensure no other process is trying to SELECT OR INSERT the same record by locking
|
37
|
+
# the entire table (read + write) during the transaction
|
37
38
|
connection.execute("LOCK TABLE #{table_name} IN EXCLUSIVE MODE")
|
38
39
|
m = first || create
|
39
40
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module CachedSingleton
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = '0.0.2'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cached_singleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault El Zamek, Cédric Darné, Lionel Oto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,17 +28,20 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: ! ' CachedSingleton makes a single instance ActiveRecord object behave
|
42
|
+
fully like a singleton.
|
43
|
+
|
44
|
+
'
|
42
45
|
email:
|
43
46
|
- thibault.elzamek@c4mprod.com, cedric.darne@c4mprod.com, lionel.oto@c4mprod.com
|
44
47
|
executables: []
|
@@ -47,8 +50,8 @@ extra_rdoc_files: []
|
|
47
50
|
files:
|
48
51
|
- LICENSE.txt
|
49
52
|
- README.md
|
50
|
-
- lib/cached_singleton/version.rb
|
51
53
|
- lib/cached_singleton/cached_singleton.rb
|
54
|
+
- lib/cached_singleton/version.rb
|
52
55
|
- lib/cached_singleton.rb
|
53
56
|
- spec/cached_singleton_spec.rb
|
54
57
|
homepage: https://github.com/c4mprod/cached_singleton
|
@@ -61,19 +64,19 @@ require_paths:
|
|
61
64
|
- lib
|
62
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
66
|
requirements:
|
64
|
-
- - '>='
|
67
|
+
- - ! '>='
|
65
68
|
- !ruby/object:Gem::Version
|
66
69
|
version: '0'
|
67
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
71
|
requirements:
|
69
|
-
- - '>='
|
72
|
+
- - ! '>='
|
70
73
|
- !ruby/object:Gem::Version
|
71
74
|
version: '0'
|
72
75
|
requirements: []
|
73
76
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.0.8
|
75
78
|
signing_key:
|
76
79
|
specification_version: 4
|
77
|
-
summary:
|
80
|
+
summary: Makes an active record behave like a singleton
|
78
81
|
test_files:
|
79
82
|
- spec/cached_singleton_spec.rb
|