Пример #1
0
        /**
         * Adds a specified entry to the cache or replaces an entry associated with the same globe.
         *
         * @param entry the entry to add. If null, the cache remains unchanged.
         */
        public void addEntry(ShapeDataCacheEntry entry)
        {
            if (entry == null)
            {
                return;
            }

            this.entries.put(entry.globeStateKey, entry);
            entry.lastUsed = System.currentTimeMillis();
        }
Пример #2
0
        /**
         * Retrieves a specified entry from the cache.
         * <p/>
         * Note: Each time this method is called the cache is cleared of dead entries, as defined by their last-used time
         * relative to this cache's maximum unused time.
         *
         * @param globe the globe the entry is associated with.
         *
         * @return the entry if it exists, otherwise null.
         */
        public ShapeDataCacheEntry getEntry(Globe globe)
        {
            long now = System.currentTimeMillis();

//        this.removeDeadEntries(now);

            if (globe == null)
            {
                return(null);
            }

            ShapeDataCacheEntry entry = this.entries.get(globe.getGlobeStateKey());

            if (entry != null)
            {
                entry.lastUsed = now;
            }

            return(entry);
        }