Class: CacheControl
- Inherits:
-
Object
- Object
- CacheControl
- Defined in:
- lib/cache_control.rb
Overview
Copyright IBM Corp. 2015
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Constant Summary collapse
- @@cache_ttl =
This class is meant to control how often the application updates ttl = how many seconds the application waits before updating last_accessed = when you last accessed the application
600- @@cache_last_accessed =
Time.now
Instance Method Summary collapse
-
#always_cache_update ⇒ Object
Sets cache_ttl to 0 so cache will update every time.
- #get_last_accessed_time ⇒ Object
- #get_ttl ⇒ Object
- #set_last_accessed_time(time) ⇒ Object
- #set_ttl(seconds) ⇒ Object
-
#turn_off_cache_update ⇒ Object
Sets cache_ttl to a high number so it never (rarely) updates.
Instance Method Details
#always_cache_update ⇒ Object
Sets cache_ttl to 0 so cache will update every time
41 42 43 |
# File 'lib/cache_control.rb', line 41 def always_cache_update @@cache_ttl = 0 end |
#get_last_accessed_time ⇒ Object
45 46 47 |
# File 'lib/cache_control.rb', line 45 def get_last_accessed_time @@cache_last_accessed end |
#get_ttl ⇒ Object
27 28 29 |
# File 'lib/cache_control.rb', line 27 def get_ttl @@cache_ttl end |
#set_last_accessed_time(time) ⇒ Object
49 50 51 |
# File 'lib/cache_control.rb', line 49 def set_last_accessed_time(time) @@cache_last_accessed = time end |
#set_ttl(seconds) ⇒ Object
31 32 33 |
# File 'lib/cache_control.rb', line 31 def set_ttl(seconds) @@cache_ttl = seconds end |
#turn_off_cache_update ⇒ Object
Sets cache_ttl to a high number so it never (rarely) updates
36 37 38 |
# File 'lib/cache_control.rb', line 36 def turn_off_cache_update @@cache_ttl = 9999999999 end |