ruby on rails - Query caching in controller -


rails 3.2.18
ruby 1.9.3
redis

checking caching in development environment.

development.rb:

s2yd::application.configure   # settings specified here take precedence on in config/application.rb    # in development environment application's code reloaded on   # every request.  slows down response time perfect development   # since don't have restart webserver when make code changes.   config.cache_classes = false    #config.assets.enabled = true   # log error messages when accidentally call methods on nil.   config.whiny_nils = true    # show full error reports , disable caching   config.consider_all_requests_local       = true   config.action_controller.perform_caching = false    # don't care if mailer can't send   config.action_mailer.raise_delivery_errors = false    # print deprecation notices rails logger   config.active_support.deprecation = :log    # use best-standards-support built browsers   config.action_dispatch.best_standards_support = :builtin    config.cache_store = :redis_store, 'redis://localhost:6379/0/cache', { expires_in: 90.minutes, namespace: 'production' } 

controller

  @restaurants = rails.cache.fetch("api/restaurants/#{@thirdparty.name}/1", expires_in: 90.minutes)     restaurant     .joins(:thirdparties, :franchise)     .includes(:menu_sections, :menus)     .where("`thirdparties`.`id` = ? , `restaurants`.`active` = ? , lower(`restaurants`.`name`) <> ?", @thirdparty.id, true, 'drinks')   end 

log

processing api::v1controller#restaurants json   parameters: {"token"=>"eatstreet"}    (0.5ms)  select count(*) `domains`    domain load (0.6ms)  select `domains`.* `domains`    domain load (0.5ms)  select `domains`.* `domains` limit 1   domain: 127.0.0.1 -> s2yd   user load (0.6ms)  select `users`.* `users` `users`.`id` = 93626 limit 1   thirdparty load (0.5ms)  select `thirdparties`.* `thirdparties` `thirdparties`.`access_token` = 'eatstreet' limit 1   thirdparty: eatstreet   restaurant load (21.7ms)  select `restaurants`.* `restaurants` inner join `restaurants_thirdparties` on `restaurants_thirdparties`.`restaurant_id` = `restaurants`.`id` inner join `thirdparties` on `thirdparties`.`id` = `restaurants_thirdparties`.`thirdparty_id` inner join `franchises` on `franchises`.`id` = `restaurants`.`franchise_id` (`thirdparties`.`id` = 3 , `restaurants`.`active` = 1 , lower(`restaurants`.`name`) <> 'drinks')   menu load (10.2ms)  select `menus`.* `menus` `menus`.`restaurant_id` in (4, 6, 7, 8, 10, 12, 14, 286, 287, 288, 322, 352, 353, 355, 394, 467, 480, 503, 523, 552, 553, 555, 615, 641, 650, 744, 785, 790, 793, 797, 799, 800, 801, 802, 807, 834, 835, 863, 865, 882, 954, 1012, 1014, 1110, 1111, 1114, 1128, 1139, 1188, 1191, 1196, 1198, 1202, 1206, 1225, 1297, 1325, 1358, 1379, 1387, 1404, 1436, 1509, 1510, 1519, 18, 39, 46, 49, 62, 66, 67, 86, 112, 129, 199, 203, 205, 209, 228, 296, 305, 306, 365, 368, 381, 382, 384, 390, 395, 496, 501, 510, 561, 565, 584, 607, 694, 767, 825, 839, 857, 926, 946, 947, 970, 996, 1000, 1028, 1040, 1055, 1071, 1094, 1109, 1160, 1216, 1244, 1339, 1355, 1356, 1364, 1375, 1418, 1438, 1448, 1508, 1518, 1527, 1564, 131, 132, 134, 135, 139, 142, 218, 249, 308, 309, 310, 324, 339, 350, 351, 361, 363, 367, 369, 370, 392, 396, 400, 490, 581, 585, 597, 836, 849, 993, 1118, 1119, 1122, 1140, 1173, 1218, 1226, 1245, 1246, 1247, 1248, 1249, 1254, 1255, 1259, 1260, 1262, 1266, 1272, 1301, 1308, 1316, 1318, 1335, 1351, 1405, 1408, 1451, 1513, 146, 149, 152, 155, 160, 161, 163, 165, 167, 190, 193, 194, 283, 291, 294, 334, 345, 346, 347, 360, 388, 426, 427, 519, 536, 577, 588, 606, 712, 798, 921, 1043, 1155, 1238, 1258, 1287, 1376, 1381, 1385, 1386, 1413, 1417, 1430, 1433, 1440, 1441, 1479, 1480, 1481, 1482, 1558, 255, 256, 259, 276, 446, 453, 456, 458, 460, 461, 462, 464, 465, 466, 468, 470, 471, 474, 491, 494, 514, 558, 626, 683, 697, 730, 748, 780, 786, 842, 858, 1015, 1161, 1197, 1357, 1371, 1373, 1444, 1453, 374, 377, 378, 401, 498, 499, 528, 564, 573, 636, 809, 909, 933, 944, 407, 409, 417, 455, 476, 479, 517, 560, 591, 604, 709, 754, 771, 833, 1072, 1073, 1074, 1099, 1185, 419, 420, 436, 437, 440, 441, 492, 507, 508, 605, 634, 648, 651, 655, 710, 729, 824, 860, 1181, 1207, 1227, 1239, 1253, 1269, 1270, 1271, 1286, 1310, 1311, 1312, 1313, 1321, 1322, 1343, 1344, 1345, 1346, 1382, 1383, 1416, 488, 543, 568, 571, 598, 622, 625, 724, 1022, 1235, 1288, 1298, 1299, 1302, 1320, 1323, 1334, 1349, 1412, 1429, 1439, 1449, 1450, 1454, 1486, 1515, 1516, 1517, 1520, 1523, 529, 537, 546, 590, 608, 609, 610, 624, 680, 681, 685, 716, 831, 1150, 1151, 1153, 1178, 1186, 1363, 1512, 1514, 638, 695, 715, 717, 718, 719, 753, 781, 837, 845, 848, 850, 960, 1027, 1129, 1233, 1250, 1303, 1367, 1423, 1434, 1442, 1468, 629, 631, 656, 658, 659, 665, 669, 741, 760, 769, 778, 908, 910, 915, 916, 917, 927, 937, 938, 941, 942, 943, 955, 957, 959, 972, 973, 974, 975, 976, 977, 979, 980, 992, 994, 999, 1005, 1023, 1134, 1157, 1174, 1208, 1210, 1224, 1229, 1242, 1304, 1314, 1315, 1378, 1415, 1424, 1435, 1445, 1492, 675, 1041, 1042, 1045, 1046, 1060, 1061, 1064, 1067, 1069, 1080, 1081, 1091, 1101, 1102, 1103, 1123, 1156, 1166, 1222, 1230, 1353, 1365, 1366, 1403, 1410, 1414, 1431, 1443, 1500, 1521, 722, 761, 764, 766, 768, 770, 805, 821, 822, 859, 928, 929, 930, 931, 932, 1059, 1106, 1115, 1234, 1352, 1447, 728, 731, 732, 734, 737, 738, 750, 777, 782, 794, 795, 818, 829, 841, 1029, 1063, 1068, 1105, 1182, 1183, 1256, 1275, 1278, 1348, 1372, 1406, 1566, 854, 861, 862, 867, 874, 880, 881, 890, 893, 894, 895, 905, 936, 956, 1006, 1011, 1013, 1024, 1026, 1030, 1033, 1038, 1044, 1116, 1117, 1121, 1165, 1192, 1193, 1209, 1309, 876, 877, 878, 879, 899, 902, 907, 913, 1004, 1050, 1078, 1079, 1086, 1107, 1108, 1199, 1243, 1292, 1411, 1457, 1458, 1459, 1460, 1461, 1465, 1466, 1467, 1470, 1472, 1474, 1477, 1526, 1538, 1568, 1569, 1570, 1572, 1573, 1574, 1576, 1577, 1578, 1582, 1583, 1584)   menusection load (44.5ms)  select `menu_sections`.* `menu_sections` `menu_sections`.`menu_id` in (4, 160, 1885, 7, 8, 121, 10, 319, 12, 14, 130, 358, 2225, 2226, 251, 253, 305, 367, 368, 374, 447, 536, 2242, 554, 591, 618, 652, 663, 1812, 1826, 2235, 2257, 745, 1857, 804, 896, 971, 1798, 1000, 2455, 1816, 2418, 1015, 1005, 1010, 1009, 2389, 1019, 1082, 1072, 1903, 1099, 1104, 1113, 2477, 1246, 1346, 1357, 1518, 1519, 2390, 1525, 1539, 2196, 1555, 1643, 1659, 1664, 1668, 1917, 2557, 2559, 1843, 1900, 2292, 2088, 2112, 2116, 2173, 2198, 2180, 2191, 2272, 2406, 2412, 2490, 2408, 2444, 2445, 2446, 2447, 2448, 2449, 171, 172, 175, 2574, 21, 1092, 1889, 1976, 2011, 22, 669, 24, 25, 26, 686, 27, 2558, 351, 352, 31, 1018, 33, 129, 242, 1735, 1762, 1763, 95, 98, 1787, 1792, 1871, 2159, 2161, 2162, 2496, 2497, 103, 478, 1027, 148, 256, 1733, 1770, 2245, 1723, 1883, 505, 2526, 392, 399, 400, 1064, 1066, 1067, 414, 415, 416, 435, 1197, 1200, 2139, 1811, 1872, 1873, 1876, 1878, 1898, 587, 588, 590, 1326, 1979, 1987, 612, 615, 672, 680, 1841, 735, 1925, 865, 2499, 2500, 2502, 2503, 2505, 1058, 1942, 1943, 1190, 1191, 1606, 2293, 1097, 1217, 1241, 1349, 1273, 1275, 1276, 1277, 1278, 1279, 1327, 1649, 1650, 1651, 1652, 1653, 2106, 2107, 2280, 2281, 2309, 2310, 1387, 1395, 1425, 1426, 1436, 1457, 1495, 1523, 1617, 1619, 1793, 1794, 1780, 1781, 1782, 1888, 1918, 2097, 2127, 2108, 2115, 2125, 2128, 2163, 2437, 2239, 2284, 2338, 2433, 2393, 2399, 2410, 2421, 2462, 2584, 35, 265, 1116, 2054, 2113, 1696, 1751, 43, 46, 132, 2114, 2211, 2212, 2214, 2436, 2440, 287, 671, 673, 1542, 1703, 292, 2080, 309, 344, 346, 364, 2228, 366, 381, 384, 2146, 391, 1802, 393, 394, 1710, 443, 448, 2419, 568, 1186, 711, 2602, 2603, 702, 1372, 1075, 1129, 1757, 1321, 1529, 1766, 1884, 1567, 1724, 1725, 2650, 2651, 1796, 1797, 1836, 1837, 1926, 1928, 1931, 1929, 1932, 1934, 2342, 2343, 1980, 1946, 2523, 2010, 1950, 1951, 2219, 2060, 2018, 2035, 2034, 2079, 2575, 2164, 2197, 2531, 2203, 2344, 2405, 50, 395, 2150, 52, 1879, 2008, 55, 58, 62, 63, 65, 67, 159, 167, 398, 1702, 86, 89, 90, 238, 239, 240, 247, 252, 337, 2474, 1803, 2613, 545, 550, 1823, 1824, 1587, 1902, 2611, 480, 481, 630, 637, 2493, 2264, 2612, 701, 734, 1867, 870, 1448, 1325, 1455, 2000, 2279, 1579, 1863, 2546, 1936, 1940, 1974, 2223, 2176, 2190, 2555, 2643, 2179, 2216, 2222, 2178, 2215, 2217, 2675, 2232, 2256, 2261, 2295, 2582, 2321, 2352, 2353, 2396, 2397, 2364, 2371, 2372, 2560, 1127, 198, 2271, 2274, 230, 499, 1984, 1985, 519, 2204, 1989, 527, 528, 529, 1765, 533, 534, 539, 541, 542, 548, 569, 570, 2265, 2266, 2004, 2006, 1817, 766, 854, 863, 864, 894, 1905, 2529, 962, 978, 1079, 1916, 2556, 1359, 1604, 2282, 1821, 2109, 2111, 2154, 2155, 2480, 2313, 2341, 2348, 423, 425, 2233, 2247, 421, 2134, 2135, 2136, 420, 450, 452, 581, 2335, 583, 584, 678, 799, 1400, 683, 687, 708, 1418, 771, 822, 1033, 1175, 2165, 1239, 1259, 1265, 458, 2573, 460, 472, 518, 565, 551, 1865, 2229, 553, 613, 676, 715, 2206, 2498, 856, 2409, 872, 918, 953, 954, 958, 959, 960, 963, 2562, 2563, 2564, 2565, 2566, 1070, 1458, 1459, 1755, 1501, 1736, 1636, 470, 1911, 490, 1071, 2607, 1963, 1964, 494, 506, 1324, 2463, 2600, 2601, 600, 1743, 751, 1679, 1691, 800, 1795, 2147, 2646, 814, 1699, 817, 818, 868, 1632, 1052, 1103, 1778, 1640, 1708, 1838, 1868, 1870, 1933, 1956, 1960, 2609, 1959, 2608, 2007, 2019, 2028, 2645, 2020, 2610, 2021, 2022, 2059, 2057, 2102, 2103, 2089, 2090, 2181, 2182, 2236, 1734, 2071, 2101, 2083, 1832, 1464, 1808, 1927, 724, 760, 770, 782, 885, 2407, 1969, 1970, 1971, 1861, 2156, 2031, 2030, 2032, 2033, 2046, 2055, 2056, 2048, 2063, 2314, 2218, 2385, 2294, 2328, 2339, 2350, 2382, 2383, 2359, 2411, 2414, 2415, 2413, 2452, 2416, 2438, 2430, 632, 653, 2401, 655, 679, 2244, 2604, 2539, 2540, 750, 1534, 1839, 1840, 769, 883, 2606, 943, 2605, 866, 874, 1068, 1086, 1576, 1575, 2395, 1578, 1625, 1638, 1827, 2124, 2402, 2441, 2521, 907, 903, 873, 2188, 875, 2289, 880, 1470, 2423, 2442, 891, 2479, 2519, 916, 966, 2095, 2595, 1083, 1968, 1685, 2243, 1088, 2476, 1263, 1272, 1383, 2495, 1541, 1784, 1999, 2596, 1935, 2494, 1996, 2543, 2213, 2520, 2250, 2262, 2434, 2327, 2422, 2384, 798, 2062, 2210, 2532, 831, 823, 908, 829, 1845, 834, 1858, 895, 1666, 932, 933, 945, 946, 969, 1767, 1901, 1586, 1834, 2224, 1180, 1288, 1163, 1164, 1166, 1165, 1201, 1223, 1222, 1225, 1227, 1228, 1371, 1247, 1690, 1552, 1257, 1282, 1375, 1378, 2142, 2143, 1304, 2398, 1290, 1362, 1629, 1631, 1941, 1785, 1789, 1801, 2185, 1286, 1295, 1420, 1421, 1292, 1294, 2337, 1340, 1726, 2283, 1374, 1558, 1623, 1682, 1639, 1709, 1768, 1769, 1831, 1848, 1904, 1998, 2220, 2027, 2029, 2172, 2199, 2227, 2249, 2269, 2325, 2332, 2367, 1403, 1396, 1507, 1509, 1510, 1397, 1566, 2622, 2623, 1404, 1405, 1428, 2168, 1438, 2486, 1443, 2567, 2590, 1453, 1472, 1481, 2588, 2589, 1475, 1496, 1503, 2585, 1505, 2591, 1506, 1532, 1591, 2315, 2316, 2317, 2318, 2319, 2320, 1605, 1819, 1846, 2096, 2133, 2131, 2192, 2202, 2221, 2268, 2312, 2365, 2400, 2417, 2427, 2428, 884, 935, 941, 1687, 1850, 944, 2465, 947, 1017, 1353, 2470, 1049, 1047, 1048, 1105, 1777, 1237, 2580, 2581, 1236, 1230, 1234, 2597, 2598, 1231, 1232, 2578, 1882, 1521, 1783, 1528, 1860, 2149, 2336, 920, 2471, 1669, 2002, 2267, 2647, 928, 1497, 2511, 2512, 2513, 2514, 2515, 997, 936, 919, 956, 1323, 1986, 2148, 2472, 1694, 2484, 996, 998, 1040, 1063, 1078, 1386, 1389, 1437, 1444, 2370, 1513, 1514, 1633, 1634, 1938, 1952, 1966, 2545, 2158, 2193, 2644, 1145, 1188, 2458, 1154, 1572, 1158, 1159, 1658, 2259, 2530, 1148, 1176, 1150, 1160, 1169, 2340, 1173, 1181, 1194, 1195, 1172, 1206, 2522, 1177, 1179, 1252, 2119, 1262, 1351, 2349, 2594, 1360, 1367, 1385, 1381, 2288, 2291, 2329, 2330, 1410, 1467, 1540, 1527, 1551, 1624, 2461, 1663, 1660, 2049, 2052, 2024, 2025, 1107, 1149, 1132, 1168, 1114, 1135, 1143, 1967, 1973, 1174, 1184, 1334, 1434, 1465, 1531, 1490, 1491, 2047, 1516, 1515, 1522, 1707, 1912, 2085, 2205, 2376, 2379, 2380, 2387, 2391, 2386, 2392, 2355, 2394, 2425, 2381, 2354, 2360, 2361, 2374, 2454, 2488, 2616, 2627, 2619, 2624, 2625, 2639, 2626, 2629, 2630, 2631, 2634, 2635, 2636) order `index` asc completed 200 ok in 3321.9ms (views: 3235.1ms | activerecord: 79.0ms) 

seems rails.cache.fetch doesn't work , still touches database.

i think should change config.

config.action_controller.perform_caching = false 

try change false true.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -