Ruby on Railsã§ç¹å®ã®å¤ãã¯ã¨ãªçµæããã£ãã·ã¥ããããã¿ã¨ãã¦Rails.cacheãç´¹ä»ãã¾ãã ãã®æ©è½ã使ãã¨ãæå¹æéãè¨å®ãããããã£ãã·ã¥å 容ãå§ç¸®ã§ãã¾ã ð ã¡ã½ããRails.cache.fetchRails.cache.fetchã¯ãã£ãã·ã¥ãããå¤ãåå¾ããã¡ã½ããã§ãã ãããã¯ã渡ããã¨ã§ããã£ãã·ã¥ããªãã£ãå ´åã¯æå®ããããã¼ã¿ããã£ãã·ã¥ã«ã»ãããã¦è¿ããã¨ãã§ãã¾ãã def cached_title Rails.cache.fetch("/model/article/title/#{id}", expired_in: 1.hour) do Article.find(id).title end end
{{#tags}}- {{label}}
{{/tags}}