mongodb_cache_store 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b09d07e52df5625b37a6bc5294b71426a18ef328ef7e737d5ce5b8751ad8f1e6
4
+ data.tar.gz: f57c588b1b179f4207daa6a4f8ab21847a839767e264112e9c47b9856137c4ab
5
+ SHA512:
6
+ metadata.gz: f84fe15d051c5f37fe4863a46cc4b0a5e731e0cc5b922ac7d38d2ba2363835955d71515aa4d5ae2c2509d120957c961c4347e7e32476926ab560c8dda8763220
7
+ data.tar.gz: 6c3f9fca66b07f3acec07fe6d85a10cc96ab7f89d111721d4cb3aeb122d91aaa161eaf41bc5be8936440f2de30f7a15ef485becaa69c22f82644d2e7f51f4795
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ ./idea/
data/.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.5.1-p57" project-jdk-type="RUBY_SDK" />
7
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/mongodb_cache_store.iml" filepath="$PROJECT_DIR$/.idea/mongodb_cache_store.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <excludeFolder url="file://$MODULE_DIR$/lib/active_support/cache" />
9
+ </content>
10
+ <orderEntry type="inheritedJdk" />
11
+ <orderEntry type="sourceFolder" forTests="false" />
12
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v5.1.6, ruby-2.5.1-p57) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v5.2.1, ruby-2.5.1-p57) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bson (v4.3.0, ruby-2.5.1-p57) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.6, ruby-2.5.1-p57) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.0.5, ruby-2.5.1-p57) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, ruby-2.5.1-p57) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.1.1, ruby-2.5.1-p57) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, ruby-2.5.1-p57) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="mongo (v2.6.2, ruby-2.5.1-p57) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="mongoid (v6.2.1, ruby-2.5.1-p57) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.5.1-p57) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.8.0, ruby-2.5.1-p57) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.8.0, ruby-2.5.1-p57) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.8.2, ruby-2.5.1-p57) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.8.0, ruby-2.5.1-p57) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.8.0, ruby-2.5.1-p57) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, ruby-2.5.1-p57) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.5, ruby-2.5.1-p57) [gem]" level="application" />
30
+ </component>
31
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,518 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="b2ea6f09-c7b6-4de1-aa4f-423d901436fe" name="Default Changelist" comment="">
5
+ <change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
6
+ <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
7
+ <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
8
+ <change afterPath="$PROJECT_DIR$/.idea/mongodb_cache_store.iml" afterDir="false" />
9
+ <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
10
+ <change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
11
+ <change afterPath="$PROJECT_DIR$/.rspec" afterDir="false" />
12
+ <change afterPath="$PROJECT_DIR$/.travis.yml" afterDir="false" />
13
+ <change afterPath="$PROJECT_DIR$/CODE_OF_CONDUCT.md" afterDir="false" />
14
+ <change afterPath="$PROJECT_DIR$/Gemfile" afterDir="false" />
15
+ <change afterPath="$PROJECT_DIR$/LICENSE.txt" afterDir="false" />
16
+ <change afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
17
+ <change afterPath="$PROJECT_DIR$/Rakefile" afterDir="false" />
18
+ <change afterPath="$PROJECT_DIR$/bin/console" afterDir="false" />
19
+ <change afterPath="$PROJECT_DIR$/bin/setup" afterDir="false" />
20
+ <change afterPath="$PROJECT_DIR$/lib/active_support/cache/mongo_db_cache_store.rb" afterDir="false" />
21
+ <change afterPath="$PROJECT_DIR$/lib/active_support/cache/mongo_id_cache_store.rb" afterDir="false" />
22
+ <change afterPath="$PROJECT_DIR$/lib/mongodb_cache_store.rb" afterDir="false" />
23
+ <change afterPath="$PROJECT_DIR$/lib/mongodb_cache_store/version.rb" afterDir="false" />
24
+ <change afterPath="$PROJECT_DIR$/mongodb_cache_store.gemspec" afterDir="false" />
25
+ <change afterPath="$PROJECT_DIR$/spec/mongodb_cache_store_spec.rb" afterDir="false" />
26
+ <change afterPath="$PROJECT_DIR$/spec/mongoid.yml" afterDir="false" />
27
+ <change afterPath="$PROJECT_DIR$/spec/spec_helper.rb" afterDir="false" />
28
+ </list>
29
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
30
+ <option name="SHOW_DIALOG" value="false" />
31
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
32
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
33
+ <option name="LAST_RESOLUTION" value="IGNORE" />
34
+ </component>
35
+ <component name="CoverageDataManager">
36
+ <SUITE FILE_PATH="coverage/mongodb_cache_store@MongodbCacheStore_does_something_useful__mongodb_cache_store.rcov" NAME="MongodbCacheStore does something useful: mongodb_cache_store Coverage Results" MODIFIED="1539828520212" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="mongodb_cache_store" />
37
+ </component>
38
+ <component name="FUSProjectUsageTrigger">
39
+ <session id="-1091663257">
40
+ <usages-collector id="statistics.lifecycle.project">
41
+ <counts>
42
+ <entry key="project.closed" value="4" />
43
+ <entry key="project.open.time.0" value="1" />
44
+ <entry key="project.open.time.6" value="2" />
45
+ <entry key="project.open.time.7" value="1" />
46
+ <entry key="project.open.time.9" value="1" />
47
+ <entry key="project.opened" value="5" />
48
+ </counts>
49
+ </usages-collector>
50
+ <usages-collector id="statistics.file.extensions.open">
51
+ <counts>
52
+ <entry key="Gemfile" value="1" />
53
+ <entry key="gemspec" value="3" />
54
+ <entry key="gitignore" value="2" />
55
+ <entry key="md" value="1" />
56
+ <entry key="rb" value="22" />
57
+ <entry key="yml" value="1" />
58
+ </counts>
59
+ </usages-collector>
60
+ <usages-collector id="statistics.file.types.open">
61
+ <counts>
62
+ <entry key="Markdown" value="1" />
63
+ <entry key="PLAIN_TEXT" value="2" />
64
+ <entry key="Ruby" value="26" />
65
+ <entry key="YAML" value="1" />
66
+ </counts>
67
+ </usages-collector>
68
+ <usages-collector id="statistics.file.extensions.edit">
69
+ <counts>
70
+ <entry key="gemspec" value="368" />
71
+ <entry key="gitignore" value="15" />
72
+ <entry key="md" value="43" />
73
+ <entry key="rb" value="1032" />
74
+ <entry key="yml" value="63" />
75
+ </counts>
76
+ </usages-collector>
77
+ <usages-collector id="statistics.file.types.edit">
78
+ <counts>
79
+ <entry key="Markdown" value="43" />
80
+ <entry key="PLAIN_TEXT" value="15" />
81
+ <entry key="Ruby" value="1400" />
82
+ <entry key="YAML" value="63" />
83
+ </counts>
84
+ </usages-collector>
85
+ </session>
86
+ </component>
87
+ <component name="FileEditorManager">
88
+ <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
89
+ <file pinned="false" current-in-tab="true">
90
+ <entry file="file://$PROJECT_DIR$/mongodb_cache_store.gemspec">
91
+ <provider selected="true" editor-type-id="text-editor">
92
+ <state relative-caret-position="653">
93
+ <caret line="38" selection-start-line="38" selection-end-line="39" />
94
+ </state>
95
+ </provider>
96
+ </entry>
97
+ </file>
98
+ <file pinned="false" current-in-tab="false">
99
+ <entry file="file://$PROJECT_DIR$/lib/active_support/cache/mongo_db_cache_store.rb">
100
+ <provider selected="true" editor-type-id="text-editor">
101
+ <state relative-caret-position="-544">
102
+ <caret line="24" column="34" selection-start-line="24" selection-start-column="34" selection-end-line="24" selection-end-column="34" />
103
+ </state>
104
+ </provider>
105
+ </entry>
106
+ </file>
107
+ <file pinned="false" current-in-tab="false">
108
+ <entry file="file://$PROJECT_DIR$/lib/mongodb_cache_store.rb">
109
+ <provider selected="true" editor-type-id="text-editor">
110
+ <state relative-caret-position="38">
111
+ <caret line="2" column="51" selection-start-line="2" selection-start-column="51" selection-end-line="2" selection-end-column="51" />
112
+ </state>
113
+ </provider>
114
+ </entry>
115
+ </file>
116
+ <file pinned="false" current-in-tab="false">
117
+ <entry file="file://$PROJECT_DIR$/spec/mongoid.yml">
118
+ <provider selected="true" editor-type-id="text-editor">
119
+ <state relative-caret-position="95">
120
+ <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
121
+ </state>
122
+ </provider>
123
+ </entry>
124
+ </file>
125
+ <file pinned="false" current-in-tab="false">
126
+ <entry file="file://$PROJECT_DIR$/lib/active_support/cache/mongo_id_cache_store.rb">
127
+ <provider selected="true" editor-type-id="text-editor">
128
+ <state relative-caret-position="855">
129
+ <caret line="45" column="34" selection-start-line="45" selection-start-column="34" selection-end-line="45" selection-end-column="34" />
130
+ </state>
131
+ </provider>
132
+ </entry>
133
+ </file>
134
+ <file pinned="false" current-in-tab="false">
135
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid/clients.rb">
136
+ <provider selected="true" editor-type-id="text-editor">
137
+ <state relative-caret-position="1254">
138
+ <caret line="66" column="51" selection-start-line="66" selection-start-column="51" selection-end-line="66" selection-end-column="51" />
139
+ </state>
140
+ </provider>
141
+ </entry>
142
+ </file>
143
+ <file pinned="false" current-in-tab="false">
144
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid/clients/factory.rb">
145
+ <provider selected="true" editor-type-id="text-editor">
146
+ <state relative-caret-position="456">
147
+ <caret line="24" selection-start-line="24" selection-end-line="25" />
148
+ </state>
149
+ </provider>
150
+ </entry>
151
+ </file>
152
+ <file pinned="false" current-in-tab="false">
153
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid/config.rb">
154
+ <provider selected="true" editor-type-id="text-editor">
155
+ <state relative-caret-position="684">
156
+ <caret line="36" column="55" selection-start-line="36" selection-start-column="55" selection-end-line="36" selection-end-column="55" />
157
+ </state>
158
+ </provider>
159
+ </entry>
160
+ </file>
161
+ </leaf>
162
+ </component>
163
+ <component name="FileTemplateManagerImpl">
164
+ <option name="RECENT_TEMPLATES">
165
+ <list>
166
+ <option value="Ruby Class Template" />
167
+ </list>
168
+ </option>
169
+ </component>
170
+ <component name="Git.Settings">
171
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
172
+ </component>
173
+ <component name="IdeDocumentHistory">
174
+ <option name="CHANGED_PATHS">
175
+ <list>
176
+ <option value="$PROJECT_DIR$/lib/active_support/cache/mongo_store.rb" />
177
+ <option value="$PROJECT_DIR$/.gitignore" />
178
+ <option value="$PROJECT_DIR$/README.md" />
179
+ <option value="$PROJECT_DIR$/lib/active_support/cache/mongoid_store.rb" />
180
+ <option value="$PROJECT_DIR$/lib/active_support/cache/mongo_id_store.rb" />
181
+ <option value="$PROJECT_DIR$/spec/mongoid.yml" />
182
+ <option value="$PROJECT_DIR$/lib/active_support/cache/mongo_db_store.rb" />
183
+ <option value="$PROJECT_DIR$/lib/mongodb_cache_store.rb" />
184
+ <option value="$PROJECT_DIR$/lib/active_support/cache/mongo_db_cache_store.rb" />
185
+ <option value="$PROJECT_DIR$/lib/active_support/cache/mongo_id_cache_store.rb" />
186
+ <option value="$PROJECT_DIR$/spec/mongodb_cache_store_spec.rb" />
187
+ <option value="$PROJECT_DIR$/mongodb_cache_store.gemspec" />
188
+ </list>
189
+ </option>
190
+ </component>
191
+ <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
192
+ <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
193
+ <component name="JsGulpfileManager">
194
+ <detection-done>true</detection-done>
195
+ <sorting>DEFINITION_ORDER</sorting>
196
+ </component>
197
+ <component name="ProjectFrameBounds">
198
+ <option name="x" value="265" />
199
+ <option name="y" value="70" />
200
+ <option name="width" value="1500" />
201
+ <option name="height" value="901" />
202
+ </component>
203
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
204
+ <component name="ProjectView">
205
+ <navigator proportions="" version="1">
206
+ <foldersAlwaysOnTop value="true" />
207
+ </navigator>
208
+ <panes>
209
+ <pane id="Scope" />
210
+ <pane id="ProjectPane">
211
+ <subPane>
212
+ <expand>
213
+ <path>
214
+ <item name="mongodb_cache_store" type="b2602c69:ProjectViewProjectNode" />
215
+ <item name="mongodb_cache_store" type="462c0819:PsiDirectoryNode" />
216
+ </path>
217
+ <path>
218
+ <item name="mongodb_cache_store" type="b2602c69:ProjectViewProjectNode" />
219
+ <item name="mongodb_cache_store" type="462c0819:PsiDirectoryNode" />
220
+ <item name="spec" type="462c0819:PsiDirectoryNode" />
221
+ </path>
222
+ </expand>
223
+ <select />
224
+ </subPane>
225
+ </pane>
226
+ </panes>
227
+ </component>
228
+ <component name="PropertiesComponent">
229
+ <property name="WebServerToolWindowFactoryState" value="false" />
230
+ <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
231
+ <property name="nodejs_npm_path_reset_for_default_project" value="true" />
232
+ <property name="settings.editor.selected.configurable" value="configurable.group.appearance" />
233
+ <property name="settings.editor.splitter.proportion" value="0.2" />
234
+ </component>
235
+ <component name="RunDashboard">
236
+ <option name="ruleStates">
237
+ <list>
238
+ <RuleState>
239
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
240
+ </RuleState>
241
+ <RuleState>
242
+ <option name="name" value="StatusDashboardGroupingRule" />
243
+ </RuleState>
244
+ </list>
245
+ </option>
246
+ </component>
247
+ <component name="RunManager">
248
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
249
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
250
+ <module name="mongodb_cache_store" />
251
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="" />
252
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
253
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
254
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
255
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
256
+ <envs>
257
+ <env name="JRUBY_OPTS" value="-X+O" />
258
+ </envs>
259
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
260
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
261
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" />
262
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
263
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/mongodb_cache_store_spec.rb" />
264
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
265
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
266
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="MongodbCacheStore does something useful" />
267
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
268
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
269
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
270
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
271
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
272
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
273
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
274
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
275
+ <method v="2" />
276
+ </configuration>
277
+ <recent_temporary>
278
+ <list>
279
+ <item itemvalue="RSpec.MongodbCacheStore does something useful: mongodb_cache_store" />
280
+ </list>
281
+ </recent_temporary>
282
+ </component>
283
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" />
284
+ <component name="SvnConfiguration">
285
+ <configuration />
286
+ </component>
287
+ <component name="TaskManager">
288
+ <task active="true" id="Default" summary="Default task">
289
+ <changelist id="b2ea6f09-c7b6-4de1-aa4f-423d901436fe" name="Default Changelist" comment="" />
290
+ <created>1539584889690</created>
291
+ <option name="number" value="Default" />
292
+ <option name="presentableId" value="Default" />
293
+ <updated>1539584889690</updated>
294
+ <workItem from="1539584891195" duration="3648000" />
295
+ <workItem from="1539650886758" duration="6441000" />
296
+ <workItem from="1539738764457" duration="19492000" />
297
+ <workItem from="1539821670585" duration="4923000" />
298
+ <workItem from="1539831930202" duration="4587000" />
299
+ </task>
300
+ <servers />
301
+ </component>
302
+ <component name="TestHistory">
303
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 00m 38s.xml">
304
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
305
+ </history-entry>
306
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 06m 51s.xml">
307
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
308
+ </history-entry>
309
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 10m 15s.xml">
310
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
311
+ </history-entry>
312
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 14m 56s.xml">
313
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
314
+ </history-entry>
315
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 15m 19s.xml">
316
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
317
+ </history-entry>
318
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 20m 15s.xml">
319
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
320
+ </history-entry>
321
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 13h 20m 53s.xml">
322
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
323
+ </history-entry>
324
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 14h 49m 54s.xml">
325
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
326
+ </history-entry>
327
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.17 at 14h 50m 23s.xml">
328
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
329
+ </history-entry>
330
+ <history-entry file="MongodbCacheStore_does_something_useful__mongodb_cache_store - 2018.10.18 at 10h 08m 44s.xml">
331
+ <configuration name="MongodbCacheStore does something useful: mongodb_cache_store" configurationId="RSpecRunConfigurationType" />
332
+ </history-entry>
333
+ </component>
334
+ <component name="TimeTrackingManager">
335
+ <option name="totallyTimeSpent" value="39091000" />
336
+ </component>
337
+ <component name="ToolWindowManager">
338
+ <frame x="265" y="70" width="1500" height="901" extended-state="0" />
339
+ <layout>
340
+ <window_info content_ui="combo" x="848" y="61" width="223" height="917" id="Project" order="0" visible="true" weight="0.28333333" />
341
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
342
+ <window_info id="Favorites" order="2" side_tool="true" />
343
+ <window_info anchor="bottom" id="Messages" order="0" visible="true" weight="0.3293348" />
344
+ <window_info anchor="bottom" id="Event Log" order="1" sideWeight="0.50069445" side_tool="true" weight="0.32898173" />
345
+ <window_info anchor="bottom" id="Run" order="2" weight="0.3772846" />
346
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
347
+ <window_info anchor="bottom" id="Version Control" order="4" />
348
+ <window_info active="true" anchor="bottom" id="Terminal" order="5" sideWeight="0.49930555" visible="true" weight="0.40469974" />
349
+ <window_info anchor="bottom" id="Message" order="6" />
350
+ <window_info anchor="bottom" id="Find" order="7" weight="0.32898173" />
351
+ <window_info anchor="bottom" id="TODO" order="8" />
352
+ <window_info anchor="bottom" id="Cvs" order="9" weight="0.25" />
353
+ <window_info anchor="bottom" id="Inspection" order="10" weight="0.4" />
354
+ <window_info anchor="bottom" id="Reviews" order="11" />
355
+ <window_info anchor="bottom" id="Docker" order="12" show_stripe_button="false" />
356
+ <window_info anchor="bottom" id="Database Changes" order="13" show_stripe_button="false" />
357
+ <window_info anchor="right" id="Database" order="0" />
358
+ <window_info anchor="right" id="Commander" order="1" weight="0.4" />
359
+ <window_info anchor="right" id="Ant Build" order="2" weight="0.25" />
360
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="3" weight="0.25" />
361
+ <window_info anchor="right" id="News Feed" order="4" />
362
+ </layout>
363
+ </component>
364
+ <component name="TypeScriptGeneratedFilesManager">
365
+ <option name="version" value="1" />
366
+ </component>
367
+ <component name="VcsContentAnnotationSettings">
368
+ <option name="myLimit" value="2678400000" />
369
+ </component>
370
+ <component name="editorHistoryManager">
371
+ <entry file="file://$PROJECT_DIR$/Gemfile">
372
+ <provider selected="true" editor-type-id="text-editor">
373
+ <state>
374
+ <caret selection-end-line="1" />
375
+ </state>
376
+ </provider>
377
+ </entry>
378
+ <entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
379
+ <provider selected="true" editor-type-id="text-editor" />
380
+ </entry>
381
+ <entry file="file://$APPLICATION_HOME_DIR$/rubystubs25/marshal.rb">
382
+ <provider selected="true" editor-type-id="text-editor">
383
+ <state relative-caret-position="3116">
384
+ <caret line="164" column="13" selection-start-line="164" selection-start-column="13" selection-end-line="164" selection-end-column="13" />
385
+ </state>
386
+ </provider>
387
+ </entry>
388
+ <entry file="file://$APPLICATION_HOME_DIR$/rubystubs25/object.rb">
389
+ <provider selected="true" editor-type-id="text-editor">
390
+ <state relative-caret-position="360">
391
+ <caret line="419" column="8" selection-start-line="419" selection-start-column="8" selection-end-line="419" selection-end-column="8" />
392
+ </state>
393
+ </provider>
394
+ </entry>
395
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongo-2.6.2/lib/mongo/collection.rb">
396
+ <provider selected="true" editor-type-id="text-editor">
397
+ <state relative-caret-position="-3369">
398
+ <caret line="566" column="16" selection-start-line="566" selection-start-column="8" selection-end-line="566" selection-end-column="19" />
399
+ </state>
400
+ </provider>
401
+ </entry>
402
+ <entry file="file://$PROJECT_DIR$/README.md">
403
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
404
+ <state split_layout="SPLIT">
405
+ <first_editor relative-caret-position="95">
406
+ <caret line="5" selection-start-line="5" selection-end-line="5" />
407
+ </first_editor>
408
+ <second_editor />
409
+ </state>
410
+ </provider>
411
+ </entry>
412
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/time.rb">
413
+ <provider selected="true" editor-type-id="text-editor">
414
+ <state relative-caret-position="246">
415
+ <caret line="39" column="9" selection-start-line="39" selection-start-column="9" selection-end-line="39" selection-end-column="9" />
416
+ </state>
417
+ </provider>
418
+ </entry>
419
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongo-2.6.2/lib/mongo/client.rb">
420
+ <provider selected="true" editor-type-id="text-editor">
421
+ <state relative-caret-position="359">
422
+ <caret line="277" column="20" lean-forward="true" selection-start-line="277" selection-start-column="20" selection-end-line="277" selection-end-column="20" />
423
+ </state>
424
+ </provider>
425
+ </entry>
426
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/hash_with_indifferent_access.rb">
427
+ <provider selected="true" editor-type-id="text-editor">
428
+ <state relative-caret-position="-77">
429
+ <caret line="232" column="23" selection-start-line="232" selection-start-column="16" selection-end-line="232" selection-end-column="23" />
430
+ </state>
431
+ </provider>
432
+ </entry>
433
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid.rb">
434
+ <provider selected="true" editor-type-id="text-editor">
435
+ <state relative-caret-position="261">
436
+ <caret line="69" column="15" selection-start-line="69" selection-start-column="15" selection-end-line="69" selection-end-column="15" />
437
+ </state>
438
+ </provider>
439
+ </entry>
440
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/cache.rb">
441
+ <provider selected="true" editor-type-id="text-editor">
442
+ <state relative-caret-position="85">
443
+ <caret line="523" column="12" selection-start-line="523" selection-start-column="12" selection-end-line="523" selection-end-column="12" />
444
+ </state>
445
+ </provider>
446
+ </entry>
447
+ <entry file="file://$PROJECT_DIR$/.gitignore">
448
+ <provider selected="true" editor-type-id="text-editor">
449
+ <state relative-caret-position="209">
450
+ <caret line="11" column="7" lean-forward="true" selection-start-line="11" selection-start-column="7" selection-end-line="11" selection-end-column="7" />
451
+ </state>
452
+ </provider>
453
+ </entry>
454
+ <entry file="file://$PROJECT_DIR$/spec/mongodb_cache_store_spec.rb">
455
+ <provider selected="true" editor-type-id="text-editor">
456
+ <state relative-caret-position="171">
457
+ <caret line="9" column="23" selection-start-line="9" selection-end-line="10" />
458
+ </state>
459
+ </provider>
460
+ </entry>
461
+ <entry file="file://$PROJECT_DIR$/lib/mongodb_cache_store.rb">
462
+ <provider selected="true" editor-type-id="text-editor">
463
+ <state relative-caret-position="38">
464
+ <caret line="2" column="51" selection-start-line="2" selection-start-column="51" selection-end-line="2" selection-end-column="51" />
465
+ </state>
466
+ </provider>
467
+ </entry>
468
+ <entry file="file://$PROJECT_DIR$/spec/mongoid.yml">
469
+ <provider selected="true" editor-type-id="text-editor">
470
+ <state relative-caret-position="95">
471
+ <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
472
+ </state>
473
+ </provider>
474
+ </entry>
475
+ <entry file="file://$PROJECT_DIR$/lib/active_support/cache/mongo_id_cache_store.rb">
476
+ <provider selected="true" editor-type-id="text-editor">
477
+ <state relative-caret-position="855">
478
+ <caret line="45" column="34" selection-start-line="45" selection-start-column="34" selection-end-line="45" selection-end-column="34" />
479
+ </state>
480
+ </provider>
481
+ </entry>
482
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid/clients.rb">
483
+ <provider selected="true" editor-type-id="text-editor">
484
+ <state relative-caret-position="1254">
485
+ <caret line="66" column="51" selection-start-line="66" selection-start-column="51" selection-end-line="66" selection-end-column="51" />
486
+ </state>
487
+ </provider>
488
+ </entry>
489
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid/clients/factory.rb">
490
+ <provider selected="true" editor-type-id="text-editor">
491
+ <state relative-caret-position="456">
492
+ <caret line="24" selection-start-line="24" selection-end-line="25" />
493
+ </state>
494
+ </provider>
495
+ </entry>
496
+ <entry file="file://D:/dev/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mongoid-6.2.1/lib/mongoid/config.rb">
497
+ <provider selected="true" editor-type-id="text-editor">
498
+ <state relative-caret-position="684">
499
+ <caret line="36" column="55" selection-start-line="36" selection-start-column="55" selection-end-line="36" selection-end-column="55" />
500
+ </state>
501
+ </provider>
502
+ </entry>
503
+ <entry file="file://$PROJECT_DIR$/lib/active_support/cache/mongo_db_cache_store.rb">
504
+ <provider selected="true" editor-type-id="text-editor">
505
+ <state relative-caret-position="-544">
506
+ <caret line="24" column="34" selection-start-line="24" selection-start-column="34" selection-end-line="24" selection-end-column="34" />
507
+ </state>
508
+ </provider>
509
+ </entry>
510
+ <entry file="file://$PROJECT_DIR$/mongodb_cache_store.gemspec">
511
+ <provider selected="true" editor-type-id="text-editor">
512
+ <state relative-caret-position="653">
513
+ <caret line="38" selection-start-line="38" selection-end-line="39" />
514
+ </state>
515
+ </provider>
516
+ </entry>
517
+ </component>
518
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at 6485785@qq.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in mongodb_cache_store.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 sgzhe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # MongodbCacheStore
2
+
3
+ A MongoDB cache store for ActiveSupport.
4
+
5
+ MongoDBCacheStore provider for the standard Rails 5.2 cache mechanism.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'mongodb_cache_store'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mongodb_cache_store
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]/mongodb_cache_store. 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
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the MongodbCacheStore project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mongodb_cache_store/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mongodb_cache_store"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,68 @@
1
+ #encoding: utf-8
2
+ require 'active_support'
3
+ require 'mongo'
4
+
5
+ module ActiveSupport
6
+ module Cache
7
+ class MongoDBCacheStore < Store
8
+
9
+ def initialize(options = {})
10
+ options[:db_uri] ||= 'mongodb://127.0.0.1:27017/rails_cache_store'
11
+ options[:collection_name] ||= :rails_caches
12
+ options[:expires_in] ||= 86400
13
+ super(options)
14
+ @client = Mongo::Client.new(@options[:db_uri])
15
+ end
16
+
17
+ def clear
18
+ collection.delete_many
19
+ end
20
+
21
+ def cleanup
22
+ collection.find(expires_at: {'$lt' => Time.now.utc.to_f}).delete_many
23
+ end
24
+
25
+ def read_entry(key, options)
26
+ query = {_id: key, expires_at: {'$gt': Time.now.to_f}}
27
+ doc = collection.find(query).first
28
+ return nil if doc.nil?
29
+ entry = doc['raw'] ? doc['value'] : deserialize(doc['value'].data)
30
+ entry.is_a?(Entry) ? entry : Entry.new(entry)
31
+ end
32
+
33
+ def write_entry(key, entry, raw: false, **options)
34
+ query = {_id: key}
35
+ updates = {'$set': {
36
+ value: raw ? entry.value : serialize(entry),
37
+ expires_at: entry.expires_at,
38
+ raw: raw
39
+ }}
40
+ collection.update_one(query, updates, upsert: true)
41
+ end
42
+
43
+ def delete_entry(key, options = nil)
44
+ collection.find(_id: key).delete_one
45
+ end
46
+
47
+ def delete_matched(matcher, options=nil)
48
+ options = merged_options(options)
49
+ collection.find(_id: key_matcher(matcher, options)).delete_many
50
+ end
51
+
52
+ def deserialize(value)
53
+ Marshal.load(value) rescue value
54
+ end
55
+
56
+ def serialize(value)
57
+ BSON::Binary.new(Marshal.dump(value))
58
+ end
59
+
60
+ def collection
61
+ @client[@options[:collection_name]]
62
+ end
63
+
64
+
65
+ end
66
+ end
67
+ end
68
+
@@ -0,0 +1,64 @@
1
+ #encoding: utf-8
2
+ require 'active_support'
3
+ require 'mongoid'
4
+
5
+ module ActiveSupport
6
+ module Cache
7
+ class MongoIdCacheStore < Store
8
+ def initialize(options = {})
9
+ options[:collection_name] ||= :rails_caches
10
+ options[:expires_in] ||= 86400
11
+ super(options)
12
+ end
13
+
14
+ def clear
15
+ collection.delete_many
16
+ end
17
+
18
+ def cleanup
19
+ collection.find(expires_at: {'$lt' => Time.now.utc.to_f}).delete_many
20
+ end
21
+
22
+ def read_entry(key, options)
23
+ query = {_id: key, expires_at: {'$gt': Time.now.to_f}}
24
+ doc = collection.find(query).first
25
+ return nil if doc.nil?
26
+ entry = doc['raw'] ? doc['value'] : deserialize(doc['value'].data)
27
+ entry.is_a?(Entry) ? entry : Entry.new(entry)
28
+ end
29
+
30
+ def write_entry(key, entry, raw: false, **options)
31
+ query = {_id: key}
32
+ updates = {'$set': {
33
+ value: raw ? entry.value : serialize(entry),
34
+ expires_at: entry.expires_at,
35
+ raw: raw
36
+ }}
37
+ collection.update_one(query, updates, upsert: true)
38
+ end
39
+
40
+ def delete_entry(key, options = nil)
41
+ collection.find(_id: key).delete_one
42
+ end
43
+
44
+ def delete_matched(matcher, options=nil)
45
+ options = merged_options(options)
46
+ collection.find(_id: key_matcher(matcher, options)).delete_many
47
+ end
48
+
49
+ def deserialize(value)
50
+ Marshal.load(value) rescue value
51
+ end
52
+
53
+ def serialize(value)
54
+ BSON::Binary.new(Marshal.dump(value))
55
+ end
56
+
57
+ private
58
+
59
+ def collection
60
+ ::Mongoid.default_client[@options[:collection_name]]
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ module MongodbCacheStore
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "mongodb_cache_store/version"
2
+ require 'active_support/cache/mongo_db_cache_store'
3
+ require 'active_support/cache/mongo_id_cache_store'
4
+ module MongodbCacheStore
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "mongodb_cache_store/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mongodb_cache_store"
8
+ spec.version = MongodbCacheStore::VERSION
9
+ spec.authors = ["sgzhe"]
10
+ spec.email = ["sgzhe@163.com"]
11
+
12
+ spec.summary = %q{ActiveSupport cache using MongoDB for Rails.}
13
+ spec.description = %q{MongoDBCacheStore provider for the standard Rails cache mechanism. Mongo is well-suited to caching.}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "activesupport", "~> 5.1"
36
+ spec.add_development_dependency "bundler", "~> 1.16"
37
+ spec.add_development_dependency "mongo", "~> 2.6"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+ spec.add_development_dependency "mongoid", "~> 6.2"
41
+
42
+
43
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongodb_cache_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sgzhe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongo
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mongoid
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '6.2'
97
+ description: MongoDBCacheStore provider for the standard Rails cache mechanism. Mongo
98
+ is well-suited to caching.
99
+ email:
100
+ - sgzhe@163.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".idea/misc.xml"
107
+ - ".idea/modules.xml"
108
+ - ".idea/mongodb_cache_store.iml"
109
+ - ".idea/vcs.xml"
110
+ - ".idea/workspace.xml"
111
+ - ".rspec"
112
+ - ".travis.yml"
113
+ - CODE_OF_CONDUCT.md
114
+ - Gemfile
115
+ - LICENSE.txt
116
+ - README.md
117
+ - Rakefile
118
+ - bin/console
119
+ - bin/setup
120
+ - lib/active_support/cache/mongo_db_cache_store.rb
121
+ - lib/active_support/cache/mongo_id_cache_store.rb
122
+ - lib/mongodb_cache_store.rb
123
+ - lib/mongodb_cache_store/version.rb
124
+ - mongodb_cache_store.gemspec
125
+ homepage: ''
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.7.6
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: ActiveSupport cache using MongoDB for Rails.
149
+ test_files: []