Jbuilder Rails Caching ist langsamer

Ich habe versucht, die Zwischenspeicherung mit Sammlungen zu verwenden (mit mehreren Lösungen). Das Problem besteht darin, dass die Antwort bei jedem Versuch, eine Zwischenspeicherung durchzuführen, langsamer wird. Betrachten Sie das folgende Beispiel einer Sammlung, in der für jedes Element (ca. 25 Elemente) 2 Teilergebnisse angezeigt werden.

json.data do
  json.array! @organizations do |organization|
    json.partial! 'api/v1/organizations/organization', organization: organization
    json.partial! 'api/v1/organizations/links', organization: organization
  end
end

ohne Zwischenspeicherung beträgt die durchschnittliche Antwortzeit etwa ~ 38 ms (im Durchschnitt)

Jetzt mit Caching

json.data do
  json.array! @organizations do |organization|
    json.cache! organization do
      json.partial! 'api/v1/organizations/organization', organization: organization
      json.partial! 'api/v1/organizations/links', organization: organization
    end
  end
end

Mit dem Jbuilder ist das Standardcaching und der Dallas Store ordnungsgemäß installiert und konfiguriert (ich konnte überprüfen, ob kein Cache-Fehler aufgetreten ist).

die durchschnittliche Antwort liegt bei ~ 59ms (im Durchschnitt)

unter Verwendung der Syntax vonCache Digest

json.data do
  json.cache! @organizations do
    json.partial! 'api/v1/organizations/organization', collection: @organizations, as: :organization
    json.partial! 'api/v1/organizations/links', collection: @organizations, as: :organization
  end
end

ie durchschnittliche Antwortzeit beträgt ~ 41 ms (im Durchschnitt), und die Antwort unterscheidet sich von den anderen Antworte

# Instead of getting
[{ data:{}, links:{} }, {{ data:{}, links:{} }]
# I get
[{ data:{}, data:{}, links:{}, links:{} }]

, aber der Cache-Digest der Datei ist eine sehr große Zeichenfolge, die leicht die maximale Länge des Dateinamens unter Unix überschreitet. Dies ist beispielsweise der Dateiname.

Cache write: jbuilder/organizations/5509f9284162643526000000-20150322012449497000000/organizations/5509e5924162643056020000-20150320223230684000000/organizations/550b54d8416264add2040000-20150321004501311000000/organizations/550e35704162640a98030000-20150322032224768000000/organizations/550e357b4162640a98050000-20150322032235260000000/organizations/550e35834162640a98080000-20150322032243162000000/organizations/550e35894162640a980a0000-20150322032249767000000/organizations/550e35904162640a980c0000-20150322032256464000000/organizations/550e35944162640a980e0000-20150322032300519000000/organizations/550e35984162640a98100000-20150322032304428000000/organizations/550e359c4162640a98120000-20150322032308542000000/organizations/550e35a04162640a98140000-20150322032312514000000/organizations/550e35a54162640a98160000-20150322032317066000000/organizations/550e35a84162640a98180000-20150322032320850000000/organizations/550e35ac4162640a981a0000-20150322032324716000000/organizations/550e35b04162640a981c0000-20150322032328643000000/organizations/550e35b54162640a981e0000-20150322032333651000000/organizations/550e35ba4162640a98200000-20150322032338114000000/organizations/550e35bd4162640a98220000-20150322032341889000000/organizations/550e35c14162640a98240000-20150322032345602000000/organizations/550e35c54162640a98260000-20150322032349739000000/3fcda1f9c320ab4284da56b4b2337cf5`

Ich habe auch müdeJbuilder Cache Multi

json.data do
  json.cache_collection! @organizations do |organization|
    json.partial! 'api/v1/organizations/organization', organization: organization
    json.partial! 'api/v1/organizations/links', organization: organization
  end
end

und die Antwort war um ~ 57ms (im Durchschnitt)

plus mit Jbuilder-Cache und Multi Ich bekomme eine Menge davon in den Protokollen

  Cache digest for app/views/api/v1/organizations/index.json.jbuilder: 3a51096b9c8da6a2cdb5b5a33ee58ea4
  Cache digest for app/views/api/v1/organizations/_organization.json.jbuilder: 4a1f1d49c90fdd867d88701f8a3fd6e1
  Cache digest for app/views/api/v1/organizations/_links.json.jbuilder: f2a881e125f95421d566edd571fdec73
  Cache digest for app/views/api/v1/organizations/index.json.jbuilder: 3a51096b9c8da6a2cdb5b5a33ee58ea4
  Cache digest for app/views/api/v1/organizations/_organization.json.jbuilder: 4a1f1d49c90fdd867d88701f8a3fd6e1
  Cache digest for app/views/api/v1/organizations/_links.json.jbuilder: f2a881e125f95421d566edd571fdec73
  Cache digest for app/views/api/v1/organizations/index.json.jbuilder: 3a51096b9c8da6a2cdb5b5a33ee58ea4
  Cache digest for app/views/api/v1/organizations/_organization.json.jbuilder: 4a1f1d49c90fdd867d88701f8a3fd6e1

so stimmt etwas mit meiner Implementierung oder Maschine oder der lokalen Umgebung nicht? Rails 4.2.0 und Jbuilder 2.2.11

Ich habe dieses Problem auch in jbuilder # 259 @ geposte

Antworten auf die Frage(4)

Ihre Antwort auf die Frage