Class: Rack::Cachely::Key
- Inherits:
-
Object
- Object
- Rack::Cachely::Key
- Includes:
- Utils
- Defined in:
- lib/rack-cachely/key.rb
Instance Method Summary collapse
-
#generate ⇒ Object
Generate a normalized cache key for the request.
-
#initialize(request) ⇒ Key
constructor
A new instance of Key.
- #to_s ⇒ Object
Constructor Details
#initialize(request) ⇒ Key
Returns a new instance of Key.
9 10 11 |
# File 'lib/rack-cachely/key.rb', line 9 def initialize(request) @request = request end |
Instance Method Details
#generate ⇒ Object
Generate a normalized cache key for the request.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rack-cachely/key.rb', line 14 def generate @key ||= begin parts = [] parts << @request.scheme << "://" parts << @request.host if @request.scheme == "https" && @request.port != 443 || @request.scheme == "http" && @request.port != 80 parts << ":" << @request.port.to_s end parts << @request.script_name parts << @request.path_info if query_string && query_string != "" parts << "?" parts << query_string end parts.join end end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/rack-cachely/key.rb', line 37 def to_s self.generate end |