infopark_cloud_connector 6.8.0.beta.200.785.05d4af9 → 6.8.0.beta.200.809.bdfa8c3
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,32 +2,29 @@
|
|
2
2
|
module RailsConnector
|
3
3
|
|
4
4
|
class Cache
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def self.begin_context
|
9
|
-
@context = true
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.end_context
|
13
|
-
@context = false
|
14
|
-
reset
|
5
|
+
def initialize(options = {})
|
6
|
+
@fallback_backend, @cache_prefix = options[:fallback_backend], options[:cache_prefix]
|
7
|
+
@cache = {}
|
15
8
|
end
|
16
9
|
|
17
|
-
def
|
18
|
-
@
|
10
|
+
def read(key)
|
11
|
+
value = @cache[key]
|
12
|
+
if !value && @fallback_backend
|
13
|
+
value = @fallback_backend.read(cache_key_for_fallback_backend(key))
|
14
|
+
@cache[key] = value
|
15
|
+
end
|
16
|
+
value
|
19
17
|
end
|
20
18
|
|
21
|
-
def
|
22
|
-
@
|
19
|
+
def write(key, value)
|
20
|
+
@fallback_backend.write(cache_key_for_fallback_backend(key), value) if @fallback_backend
|
21
|
+
@cache[key] = value
|
23
22
|
end
|
24
23
|
|
25
|
-
|
26
|
-
@cache[key] = value if @context
|
27
|
-
end
|
24
|
+
private
|
28
25
|
|
29
|
-
def
|
30
|
-
@
|
26
|
+
def cache_key_for_fallback_backend(key)
|
27
|
+
@cache_prefix ? "#{@cache_prefix}/#{key}" : key
|
31
28
|
end
|
32
29
|
end
|
33
30
|
|
@@ -3,17 +3,11 @@ module RailsConnector
|
|
3
3
|
class CouchBlob
|
4
4
|
|
5
5
|
def self.find(id, options)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:name => "Blob Load", :index => "blobs", :keys => [options[:context]]
|
11
|
-
) do
|
12
|
-
attachment = CmsBaseModel.adapter.blob_attachment(id)
|
13
|
-
Cache.store(cache_key, attachment)
|
14
|
-
end
|
6
|
+
ActiveSupport::Notifications.instrumenter.instrument("cms_load.rails_connector",
|
7
|
+
:name => "Blob Load", :index => "blobs", :keys => [options[:context]]
|
8
|
+
) do
|
9
|
+
new(id, CmsBaseModel.adapter.blob_attachment(id))
|
15
10
|
end
|
16
|
-
new(id, attachment)
|
17
11
|
end
|
18
12
|
|
19
13
|
def self.configure(spec)
|
data/lib/rails_connector/obj.rb
CHANGED
@@ -194,10 +194,6 @@ module RailsConnector
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
def object_id # :nodoc:
|
198
|
-
obj_id
|
199
|
-
end
|
200
|
-
|
201
197
|
# Returns the root Obj, i.e. the Obj with the path "/"
|
202
198
|
def self.root
|
203
199
|
Obj.find_by_path("/") or raise ResourceNotFound, "Obj.root not found: There is no Obj with path '/'."
|
@@ -2,6 +2,7 @@
|
|
2
2
|
module RailsConnector
|
3
3
|
|
4
4
|
class Revision < CmsBaseModel
|
5
|
+
CACHE_PREFIX = 'revision'
|
5
6
|
|
6
7
|
self.key_prefix = "rev"
|
7
8
|
|
@@ -9,6 +10,7 @@ module RailsConnector
|
|
9
10
|
property :base_revision_id
|
10
11
|
property :title
|
11
12
|
property :content_cache_id
|
13
|
+
property :editable
|
12
14
|
|
13
15
|
# Selects the revision with the given id as current revision
|
14
16
|
def self.current=(revision)
|
@@ -28,8 +30,29 @@ module RailsConnector
|
|
28
30
|
find_by_label("published")
|
29
31
|
end
|
30
32
|
|
33
|
+
def self.begin_caching
|
34
|
+
@editable_cache = Configuration.cache_editable_workspaces ? persistent_cache : Cache.new
|
35
|
+
@read_only_cache = persistent_cache
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.end_caching
|
39
|
+
@editable_cache = @read_only_cache = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.caching?
|
43
|
+
@read_only_cache && @editable_cache
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.cache_for(revision)
|
47
|
+
revision.editable ? @editable_cache : @read_only_cache
|
48
|
+
end
|
49
|
+
|
31
50
|
def find_obj_data_by(index, keys)
|
32
|
-
|
51
|
+
if self.class.caching?
|
52
|
+
find_obj_data_from_cache_or_database_by(index, keys)
|
53
|
+
else
|
54
|
+
find_obj_data_from_database_by(index, keys)
|
55
|
+
end
|
33
56
|
end
|
34
57
|
|
35
58
|
def chain
|
@@ -72,6 +95,10 @@ module RailsConnector
|
|
72
95
|
|
73
96
|
COMPOUND_KEY_INDICES = [:ppath].freeze
|
74
97
|
|
98
|
+
def self.persistent_cache
|
99
|
+
Cache.new(:fallback_backend => Rails.cache, :cache_prefix => CACHE_PREFIX)
|
100
|
+
end
|
101
|
+
|
75
102
|
def find_obj_data_from_database_by(index, keys)
|
76
103
|
return [] if keys.blank?
|
77
104
|
instrumenter = ActiveSupport::Notifications.instrumenter
|
@@ -86,10 +113,10 @@ module RailsConnector
|
|
86
113
|
end
|
87
114
|
|
88
115
|
def find_obj_data_from_cache_or_database_by(index, keys)
|
89
|
-
# load results from cache
|
90
116
|
keys_from_database = []
|
117
|
+
# load results from cache
|
91
118
|
results_from_cache = keys.map do |key|
|
92
|
-
|
119
|
+
cache.read(cache_key_for(index, key)).tap do |objs|
|
93
120
|
keys_from_database << key unless objs
|
94
121
|
end
|
95
122
|
end
|
@@ -128,7 +155,11 @@ module RailsConnector
|
|
128
155
|
end
|
129
156
|
|
130
157
|
def store_item_in_cache(index, key, item)
|
131
|
-
|
158
|
+
cache.write(cache_key_for(index, key), item) if self.class.caching?
|
159
|
+
end
|
160
|
+
|
161
|
+
def cache_key_for(index, key)
|
162
|
+
"#{id}/obj/#{index}/#{key}"
|
132
163
|
end
|
133
164
|
|
134
165
|
def extract_obj_data(data)
|
@@ -146,6 +177,9 @@ module RailsConnector
|
|
146
177
|
def rtc
|
147
178
|
@rtc ||= DictStorage.get(read_attribute("rtc_ref"))
|
148
179
|
end
|
149
|
-
end
|
150
180
|
|
181
|
+
def cache
|
182
|
+
self.class.cache_for(self)
|
183
|
+
end
|
184
|
+
end
|
151
185
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_cloud_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 88245288957
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 6
|
@@ -9,13 +9,12 @@ version: !ruby/object:Gem::Version
|
|
9
9
|
- 0
|
10
10
|
- beta
|
11
11
|
- 200
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
|
18
|
-
version: 6.8.0.beta.200.785.05d4af9
|
12
|
+
- 809
|
13
|
+
- bdfa
|
14
|
+
- 8
|
15
|
+
- c
|
16
|
+
- 3
|
17
|
+
version: 6.8.0.beta.200.809.bdfa8c3
|
19
18
|
platform: ruby
|
20
19
|
authors:
|
21
20
|
- Infopark AG
|
@@ -23,10 +22,11 @@ autorequire:
|
|
23
22
|
bindir: bin
|
24
23
|
cert_chain: []
|
25
24
|
|
26
|
-
date: 2012-07-
|
25
|
+
date: 2012-07-19 00:00:00 +02:00
|
27
26
|
default_executable:
|
28
27
|
dependencies:
|
29
28
|
- !ruby/object:Gem::Dependency
|
29
|
+
type: :runtime
|
30
30
|
requirement: &id001 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
@@ -38,11 +38,11 @@ dependencies:
|
|
38
38
|
- 1
|
39
39
|
- 2
|
40
40
|
version: 1.1.2
|
41
|
-
version_requirements: *id001
|
42
|
-
name: couchrest
|
43
41
|
prerelease: false
|
44
|
-
|
42
|
+
name: couchrest
|
43
|
+
version_requirements: *id001
|
45
44
|
- !ruby/object:Gem::Dependency
|
45
|
+
type: :runtime
|
46
46
|
requirement: &id002 !ruby/object:Gem::Requirement
|
47
47
|
none: false
|
48
48
|
requirements:
|
@@ -54,34 +54,32 @@ dependencies:
|
|
54
54
|
- 3
|
55
55
|
- 6
|
56
56
|
version: 1.3.6
|
57
|
-
version_requirements: *id002
|
58
|
-
name: aws-sdk
|
59
57
|
prerelease: false
|
60
|
-
|
58
|
+
name: aws-sdk
|
59
|
+
version_requirements: *id002
|
61
60
|
- !ruby/object:Gem::Dependency
|
61
|
+
type: :runtime
|
62
62
|
requirement: &id003 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - "="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
hash:
|
67
|
+
hash: 88245288957
|
68
68
|
segments:
|
69
69
|
- 6
|
70
70
|
- 8
|
71
71
|
- 0
|
72
72
|
- beta
|
73
73
|
- 200
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
|
80
|
-
version: 6.8.0.beta.200.785.05d4af9
|
81
|
-
version_requirements: *id003
|
82
|
-
name: kvom
|
74
|
+
- 809
|
75
|
+
- bdfa
|
76
|
+
- 8
|
77
|
+
- c
|
78
|
+
- 3
|
79
|
+
version: 6.8.0.beta.200.809.bdfa8c3
|
83
80
|
prerelease: false
|
84
|
-
|
81
|
+
name: kvom
|
82
|
+
version_requirements: *id003
|
85
83
|
description: The Cloud Connector for Infopark CMS Fiona enables you to develop modern, dynamic Web 2.0 applications using Ruby on Rails and at the same time display CMS managed content.
|
86
84
|
email: info@infopark.de
|
87
85
|
executables: []
|