{"action":"opened","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/4445","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/4445/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/4445/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/4445/events","html_url":"https://github.com/hazelcast/hazelcast/issues/4445","id":54770160,"number":4445,"title":"LocalRegionCache cleanup is wrong","user":{"login":"u6f6o","id":1176370,"avatar_url":"https://avatars.githubusercontent.com/u/1176370?v=3","gravatar_id":"","url":"https://api.github.com/users/u6f6o","html_url":"https://github.com/u6f6o","followers_url":"https://api.github.com/users/u6f6o/followers","following_url":"https://api.github.com/users/u6f6o/following{/other_user}","gists_url":"https://api.github.com/users/u6f6o/gists{/gist_id}","starred_url":"https://api.github.com/users/u6f6o/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/u6f6o/subscriptions","organizations_url":"https://api.github.com/users/u6f6o/orgs","repos_url":"https://api.github.com/users/u6f6o/repos","events_url":"https://api.github.com/users/u6f6o/events{/privacy}","received_events_url":"https://api.github.com/users/u6f6o/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-19T14:27:47Z","updated_at":"2015-01-19T14:27:47Z","closed_at":null,"body":"Hi, \r\n\r\nIn short: if I configure a ttl of 0 (according to documentations means eternal cache), my cache is fully evcited all the time. I added  a test method to LocalRegionCacheTest class to make it reproducible: \r\n\r\n    /**\r\n     * According to documentation (http://docs.hazelcast.org/docs/3.3/manual/html-single/hazelcast-documentation.html)\r\n     * 0 means eternal cache but instead we get evict everything all the time cache \r\n     *\r\n     * time-to-live: Maximum time in seconds for each entry to stay in the map.\r\n     * If it is not 0, entries that are older than and not updated for this time\r\n     * are evicted automatically. Valid values are integers between 0 and Integer.MAX VALUE.\r\n     * Default value is 0 and it means infinite. Moreover, if it is not 0, entries are\r\n     * evicted regardless of the set eviction-policy.\r\n     *\r\n     *\r\n     */\r\n    @Test\r\n    public void testCleanup() {\r\n        String cacheName = \"myWhatoseverMap\";\r\n\r\n        HazelcastInstance instance = mock(HazelcastInstance.class);\r\n        MapConfig mapConfig = mock(MapConfig.class);\r\n        Config config = mock(Config.class);\r\n        MaxSizeConfig maxSizeConfig = mock(MaxSizeConfig.class);\r\n\r\n        when(config.findMapConfig(eq(cacheName))).thenReturn(mapConfig);\r\n        when(mapConfig.getMaxSizeConfig()).thenReturn(maxSizeConfig);\r\n        when(instance.getConfig()).thenReturn(config);\r\n\r\n        // WITH THIS CONFIGURATION I'D ASSUME CACHE TO EVCIT NOTHING\r\n        // 5 entries in cache -> ignore\r\n        when(maxSizeConfig.getSize()).thenReturn(10);\r\n        // according to docu 0 means eternal cache\r\n        when(mapConfig.getTimeToLiveSeconds()).thenReturn(0);\r\n\r\n        LocalRegionCache localRegionCache = new LocalRegionCache(cacheName, instance, null, false);\r\n\r\n        for (int i=1; i<=5; i++) {\r\n            String key = \"key\" + i;\r\n            String value = \"value\" + i;\r\n            localRegionCache.put(key, value, value);\r\n        }\r\n\r\n        Assert.assertEquals(5, localRegionCache.size());\r\n        localRegionCache.cleanup();\r\n        Assert.assertEquals(5, localRegionCache.size());\r\n\r\n    }"}}