find_cache 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGE-LOG CHANGED
@@ -1,3 +1,9 @@
1
+ version 0.1.8
2
+ # local memorization on dynamic methods removed to prevent duplicate caching
3
+
4
+ version 0.1.7
5
+ # code cleanup and documentation
6
+
1
7
  version 0.1.6
2
8
  # after_commit on: :create, :update, :save instead of after_create, after_update, after_save callbacks
3
9
  # fix thread cache key for dynamic class methods
@@ -30,7 +30,7 @@ Or install it yourself as:
30
30
  end
31
31
 
32
32
  class UserDetail < ActiveRecord::Base
33
- has_one :user_detail
33
+ belongs_to :user
34
34
 
35
35
  # to enable belongs_to caching
36
36
  find_cache_belongs_to :user, User, :user_id
@@ -20,7 +20,7 @@ module FindCache
20
20
  # find_cache_has_one :user_detail, UserDetail, :user_id
21
21
  def find_cache_has_one(attribute, model, foreign_key)
22
22
  send :define_method, attribute.to_sym do |*args|
23
- $find_cache_store[KeyGen.global_cache_key]["#{attribute}_#{model}_#{foreign_key}_#{self.id}"] ||= model.find_cache_by_ref(foreign_key, self.id)
23
+ model.find_cache_by_ref(foreign_key, self.id)
24
24
  end
25
25
  end
26
26
 
@@ -38,7 +38,7 @@ module FindCache
38
38
  # find_cache_belongs_to :user, User, :user_id
39
39
  def find_cache_belongs_to(attribute, model, foreign_key)
40
40
  send :define_method, attribute.to_sym do |*args|
41
- $find_cache_store[KeyGen.global_cache_key]["#{attribute}_#{model}_#{foreign_key}_#{self.send(foreign_key.to_sym)}"] ||= model.find_cache(self.send(foreign_key.to_sym))
41
+ model.find_cache(self.send(foreign_key.to_sym))
42
42
  end
43
43
  end
44
44
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module FindCache
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
Binary file
@@ -426,3 +426,54 @@ Connecting to database specified by database.yml
426
426
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 10 LIMIT 1
427
427
  User Load (0.3ms) SELECT "users".* FROM "users" LIMIT 1
428
428
  Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
429
+ Connecting to database specified by database.yml
430
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" LIMIT 1
431
+  (0.1ms) begin transaction
432
+ SQL (80.8ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test content for comment"], ["created_at", Thu, 30 Aug 2012 18:12:19 UTC +00:00], ["post_id", 1], ["updated_at", Thu, 30 Aug 2012 18:12:19 UTC +00:00]]
433
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
434
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
435
+  (1.4ms) commit transaction
436
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
437
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
438
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
439
+  (0.1ms) begin transaction
440
+ SQL (0.6ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 1 content for comment"], ["created_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["post_id", 1], ["updated_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00]]
441
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
442
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
443
+  (1.4ms) commit transaction
444
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" LIMIT 1
445
+  (0.0ms) begin transaction
446
+ SQL (0.5ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 2 content for comment"], ["created_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["post_id", 1], ["updated_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00]]
447
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
448
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
449
+  (1.4ms) commit transaction
450
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
451
+  (0.0ms) begin transaction
452
+ SQL (0.5ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 3 content for comment"], ["created_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["post_id", 1], ["updated_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00]]
453
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
454
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
455
+  (1.4ms) commit transaction
456
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
457
+  (0.0ms) begin transaction
458
+ SQL (0.5ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 4 content for comment"], ["created_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["post_id", 1], ["updated_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00]]
459
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
460
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
461
+  (1.5ms) commit transaction
462
+ Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (37, 38, 39, 40) ORDER BY id ASC
463
+ Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (37, 38, 39, 40) ORDER BY id ASC
464
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
465
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
466
+  (0.1ms) begin transaction
467
+  (0.1ms) commit transaction
468
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
469
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
470
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
471
+  (0.1ms) begin transaction
472
+ SQL (29.5ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00]]
473
+ SQL (0.6ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["title", nil], ["updated_at", Thu, 30 Aug 2012 18:12:20 UTC +00:00], ["user_id", 11]]
474
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 11 LIMIT 1
475
+  (16.1ms) commit transaction
476
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 11 LIMIT 1
477
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 11 LIMIT 1
478
+ User Load (0.2ms) SELECT "users".* FROM "users" LIMIT 1
479
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: find_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -187,6 +187,7 @@ files:
187
187
  - test/dummy/tmp/cache/276/6F0/Post%2F2
188
188
  - test/dummy/tmp/cache/277/700/Post%2F3
189
189
  - test/dummy/tmp/cache/29E/F20/User%2F10
190
+ - test/dummy/tmp/cache/29F/F30/User%2F11
190
191
  - test/dummy/tmp/cache/3A8/070/Comment%2F7
191
192
  - test/dummy/tmp/cache/3A9/080/Comment%2F8
192
193
  - test/dummy/tmp/cache/3AA/090/Comment%2F9
@@ -196,6 +197,7 @@ files:
196
197
  - test/dummy/tmp/cache/3D4/D70/Comment%2F30
197
198
  - test/dummy/tmp/cache/3D5/D60/Comment%2F13
198
199
  - test/dummy/tmp/cache/3D5/D70/Comment%2F22
200
+ - test/dummy/tmp/cache/3D5/D90/Comment%2F40
199
201
  - test/dummy/tmp/cache/3D6/D70/Comment%2F14
200
202
  - test/dummy/tmp/cache/3D6/D80/Comment%2F23
201
203
  - test/dummy/tmp/cache/3D6/D90/Comment%2F32
@@ -210,7 +212,10 @@ files:
210
212
  - test/dummy/tmp/cache/3DA/DC0/Comment%2F27
211
213
  - test/dummy/tmp/cache/3DB/DC0/Comment%2F19
212
214
  - test/dummy/tmp/cache/3DB/DD0/Comment%2F28
215
+ - test/dummy/tmp/cache/3DB/DE0/Comment%2F37
213
216
  - test/dummy/tmp/cache/3DC/DE0/Comment%2F29
217
+ - test/dummy/tmp/cache/3DC/DF0/Comment%2F38
218
+ - test/dummy/tmp/cache/3DD/E00/Comment%2F39
214
219
  - test/dummy/tmp/cache/58D/B70/Post%2Fuser_id-1
215
220
  - test/find_cache_test.rb
216
221
  - test/test_helper.rb
@@ -298,6 +303,7 @@ test_files:
298
303
  - test/dummy/tmp/cache/276/6F0/Post%2F2
299
304
  - test/dummy/tmp/cache/277/700/Post%2F3
300
305
  - test/dummy/tmp/cache/29E/F20/User%2F10
306
+ - test/dummy/tmp/cache/29F/F30/User%2F11
301
307
  - test/dummy/tmp/cache/3A8/070/Comment%2F7
302
308
  - test/dummy/tmp/cache/3A9/080/Comment%2F8
303
309
  - test/dummy/tmp/cache/3AA/090/Comment%2F9
@@ -307,6 +313,7 @@ test_files:
307
313
  - test/dummy/tmp/cache/3D4/D70/Comment%2F30
308
314
  - test/dummy/tmp/cache/3D5/D60/Comment%2F13
309
315
  - test/dummy/tmp/cache/3D5/D70/Comment%2F22
316
+ - test/dummy/tmp/cache/3D5/D90/Comment%2F40
310
317
  - test/dummy/tmp/cache/3D6/D70/Comment%2F14
311
318
  - test/dummy/tmp/cache/3D6/D80/Comment%2F23
312
319
  - test/dummy/tmp/cache/3D6/D90/Comment%2F32
@@ -321,7 +328,11 @@ test_files:
321
328
  - test/dummy/tmp/cache/3DA/DC0/Comment%2F27
322
329
  - test/dummy/tmp/cache/3DB/DC0/Comment%2F19
323
330
  - test/dummy/tmp/cache/3DB/DD0/Comment%2F28
331
+ - test/dummy/tmp/cache/3DB/DE0/Comment%2F37
324
332
  - test/dummy/tmp/cache/3DC/DE0/Comment%2F29
333
+ - test/dummy/tmp/cache/3DC/DF0/Comment%2F38
334
+ - test/dummy/tmp/cache/3DD/E00/Comment%2F39
325
335
  - test/dummy/tmp/cache/58D/B70/Post%2Fuser_id-1
326
336
  - test/find_cache_test.rb
327
337
  - test/test_helper.rb
338
+ has_rdoc: