Package org.castor.cache.hashbelt.container

Examples of org.castor.cache.hashbelt.container.Container


     * Remove the oldest container from the cache and pass it to the configured reaper
     * to do its expiration work. Then clear the container and put it back into the
     * pool for further use.
     */
    private void expireCacheContainer() {
        Container expired = _cache[--_containerCount];
       
        Container[] temp = new Container[_containerCount];
        System.arraycopy(_cache, 0, temp, 0, _containerCount);
        _cache = temp;
        _cacheSize -= expired.size();
       
        _reaper.handleExpiredContainer(expired);
       
        expired.clear();
       
        _pool[_poolCount++] = expired;
    }
View Full Code Here


    public void test() {
        RefreshingReaperMock.getExpiredObjects().clear();
       
        Cache cache = new Unlimited();
       
        Container container = new MapContainer();
        for (int i = 0; i < 10; i++) {
            container.put(new Integer(i), Integer.toString(i));
        }
       
        AbstractReaper reaper = new RefreshingReaperMock();
        reaper.setCache(cache);
        reaper.handleExpiredContainer(container);
        assertEquals(10, container.size());
       
        assertEquals(10, cache.size());
        for (int i = 0; i < 10; i++) {
            Object key = new Integer(i);
            assertTrue(cache.containsKey(key));
View Full Code Here

    public void test() {
        ReinsertingReaperMock.getExpiredObjects().clear();
       
        Cache cache = new Unlimited();
       
        Container container = new MapContainer();
        for (int i = 0; i < 10; i++) {
            container.put(new Integer(i), Integer.toString(i));
        }
       
        AbstractReaper reaper = new ReinsertingReaperMock();
        reaper.setCache(cache);
        reaper.handleExpiredContainer(container);
        assertEquals(10, container.size());
       
        assertEquals(10, cache.size());
        for (int i = 0; i < 10; i++) {
            Object key = new Integer(i);
            assertTrue(cache.containsKey(key));
View Full Code Here

    public TestNotifyingReaper(final String name) { super(name); }
   
    public void test() {
        NotifyingReaperMock.getExpiredObjects().clear();
       
        Container container = new MapContainer();
        for (int i = 0; i < 10; i++) {
            container.put(new Integer(i), Integer.toString(i));
        }
       
        AbstractReaper reaper = new NotifyingReaperMock();
        reaper.handleExpiredContainer(container);
        assertEquals(10, container.size());
       
        List expired = NotifyingReaperMock.getExpiredObjects();
        assertEquals(10, expired.size());
        for (int i = 0; i < 10; i++) {
            assertTrue(expired.contains(Integer.toString(i)));
View Full Code Here

    }

    public TestNullReaper(final String name) { super(name); }
   
    public void test() {
        Container container = new MapContainer();
        for (int i = 0; i < 10; i++) {
            container.put(new Integer(i), Integer.toString(i));
        }

        AbstractReaper reaper = new NullReaper();
        reaper.handleExpiredContainer(container);
        assertEquals(10, container.size());
    }
View Full Code Here

TOP

Related Classes of org.castor.cache.hashbelt.container.Container

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.