Sha256: 9edf69ec8f33869d512c0c93c5afd484f5c6a57d60bbc8714fa1fa0d872915b1
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
# code: # * George Moschovitis <gm@navel.gr> # # (c) 2004 Navel, all rights reserved. # $Id: fragment.rb 167 2004-11-23 14:03:10Z gmosx $ require "glue/cache" require "glue/mixins" module N # = 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). # # === Design: # # Fragments are cached in the filesystem to allow for a cluster of # server to access them. Benefits over the older memory cache scheme: # # - each fragment is processed once by one server # - easier visualisation of the fragments. # - 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) # class Fragment include N::Expirable include N::LRUCache::Item # precompiled flags for fragment key "customization" ADMIN_FLAG = "-a" OWNER_FLAG = "-o" EDITOR_FLAG = "-e" VIEWER_FLAG = "-f" MY_FLAG = "-m" ANONYMOUS_FLAG = "-n" attr_accessor :body, :lm # another method for invalidation, allows for more flexible # invalidation strategies. also used by the legacy autoinvalidate # code. attr_accessor :expires def initialize(body = "", lm = Time.now) @body = body @lm = lm end 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 return @body end end end # module
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.8.0 | lib/nitro/server/fragment.rb |