lib/n/app/fragment.rb in nitro-0.1.2 vs lib/n/app/fragment.rb in nitro-0.2.0
- old
+ new
@@ -1,5 +1,16 @@
+# code:
+# * George Moschovitis <gm@navel.gr>
+#
+# (c) 2004 Navel, all rights reserved.
+# $Id: fragment.rb 99 2004-10-22 09:50:28Z gmosx $
+
+require "n/utils/cache"
+require "n/mixins"
+
+module N; module App
+
# = Fragment
#
# A Fragment is the output of a rendered script. Additional metadata
# such as lastmodified and expire times are stored to facilitate
# fragment processing (for example caching).
@@ -14,20 +25,10 @@
# - can clear the cache for all server
# - can selectively invalidate one fragment!
# - less memory per server
# - can run background cron scripts over the fragments (compression)
#
-# code:: gmosx
-#
-# (c) 2004 Navel, all rights reserved.
-# $Id: fragment.rb 71 2004-10-18 10:50:22Z gmosx $
-
-require "n/utils/cache"
-require "n/mixins"
-
-module N; module App
-
class Fragment
include N::Expirable
include N::LRUCache::Item
# precompiled flags for fragment key "customization"
@@ -53,9 +54,11 @@
def expires_after!(ea = (60*60*24))
@expires = @lm + ea
end
+ # Is the fragment expired?
+ #
def expired?
return true if @expires.nil? || (Time.now > @expires)
end
def to_str