Files
ROC/src/cache/cms_cache.e
Jocelyn Fiat 463105f29f Added feed aggregation module.
Redesigned the CMS_BLOCK system,
   - added condition attribute. It can be set via configuration file
     with
     [blocks]
      {blockid}.region={region_name}
      {blockid}.conditions[]=is_front
      {blockid}.conditions[]=path:location-path/foo/bar
   - For backward compatibility, the CMS will check only conditions for block name prefixed by "?".
Improved the configuration library to support list and table properties.
Updated theme for now, to include the feed examples.
Added "cache" classes, to ease caching of html output for instance. (TODO: improve by providing a cache manager).
2015-10-08 13:56:31 +02:00

95 lines
2.2 KiB
Plaintext

note
description: "Abstract interface for cache of value conforming to formal {G}."
date: "$Date: 2014-12-03 16:12:08 +0100 (mer., 03 déc. 2014) $"
revision: "$Revision: 96232 $"
deferred class
CMS_CACHE [G -> ANY]
feature -- Status report
exists: BOOLEAN
-- Do associated cache file exists?
deferred
end
expired (a_reference_date: detachable DATE_TIME; a_duration_in_seconds: INTEGER): BOOLEAN
-- Is associated cached item expired?
-- If `a_reference_date' is attached, cache is expired if `a_reference' is more recent than cached item.
local
d1, d2: DATE_TIME
do
if exists then
if
a_reference_date /= Void and then
a_reference_date > cache_date_time
then
Result := True
else
if a_duration_in_seconds = -1 then
Result := False -- Never expires
elseif a_duration_in_seconds = 0 then
Result := True -- Always expires
elseif a_duration_in_seconds > 0 then
d1 := cache_date_time
d2 := current_date_time
d2.second_add (- a_duration_in_seconds) --| do not modify `cache_date_time'
Result := d2 > d1 -- cached date + duration is older than current date
else
-- Invalid expiration value
-- thus always expired.
Result := True
end
end
else
Result := True
end
end
feature -- Access
item: detachable G
-- Value from the cache.
deferred
end
cache_date_time: DATE_TIME
-- Date time for current cache if exists.
-- Note: it may be UTC or not , depending on cache type.
deferred
end
cache_duration_in_seconds: INTEGER_64
-- Number of seconds since cache was set.
require
exists: exists
local
d1, d2: DATE_TIME
do
d1 := cache_date_time
d2 := current_date_time
Result := d2.relative_duration (d1).seconds_count
end
current_date_time: DATE_TIME
-- Current date time for relative duration with cache_date_time.
deferred
end
feature -- Element change
delete
-- Remove cache.
deferred
end
put (g: G)
-- Put `g' into cache.
deferred
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end