Sha256: dce8cc36f1895e64a5ec5c90b382598e9ba518ad3d69c5d2a9f17f9866eadf7b
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 112 2004-10-27 10:59:55Z gmosx $ require "n/utils/cache" require "n/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.3.0 | lib/n/server/fragment.rb |