org.springframework.util.ConcurrentReferenceHashMap.Restructure Java Examples

The following examples show how to use org.springframework.util.ConcurrentReferenceHashMap.Restructure. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void shouldPurgeOnGet() {
	this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
	for (int i = 1; i <= 5; i++) {
		this.map.put(i, String.valueOf(i));
	}
	this.map.getMockReference(1, Restructure.NEVER).queueForPurge();
	this.map.getMockReference(3, Restructure.NEVER).queueForPurge();
	assertThat(this.map.getReference(1, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(2), is("2"));
	assertThat(this.map.getReference(3, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(4), is("4"));
	assertThat(this.map.get(5), is("5"));
}
 
Example #2
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void shouldPurgeOnPut() {
	this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
	for (int i = 1; i <= 5; i++) {
		this.map.put(i, String.valueOf(i));
	}
	this.map.getMockReference(1, Restructure.NEVER).queueForPurge();
	this.map.getMockReference(3, Restructure.NEVER).queueForPurge();
	this.map.put(1, "1");
	assertThat(this.map.get(1), is("1"));
	assertThat(this.map.get(2), is("2"));
	assertThat(this.map.getReference(3, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(4), is("4"));
	assertThat(this.map.get(5), is("5"));
}
 
Example #3
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void shouldPurgeOnGet() {
	this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
	for (int i = 1; i <= 5; i++) {
		this.map.put(i, String.valueOf(i));
	}
	this.map.getMockReference(1, Restructure.NEVER).queueForPurge();
	this.map.getMockReference(3, Restructure.NEVER).queueForPurge();
	assertThat(this.map.getReference(1, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(2), is("2"));
	assertThat(this.map.getReference(3, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(4), is("4"));
	assertThat(this.map.get(5), is("5"));
}
 
Example #4
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void shouldPurgeOnPut() {
	this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
	for (int i = 1; i <= 5; i++) {
		this.map.put(i, String.valueOf(i));
	}
	this.map.getMockReference(1, Restructure.NEVER).queueForPurge();
	this.map.getMockReference(3, Restructure.NEVER).queueForPurge();
	this.map.put(1, "1");
	assertThat(this.map.get(1), is("1"));
	assertThat(this.map.get(2), is("2"));
	assertThat(this.map.getReference(3, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(4), is("4"));
	assertThat(this.map.get(5), is("5"));
}
 
Example #5
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPurgeOnGet() throws Exception {
	this.map = new TestWeakConcurrentCache<Integer, String>(1, 0.75f, 1);
	for (int i = 1; i <= 5; i++) {
		this.map.put(i, String.valueOf(i));
	}
	this.map.getMockReference(1, Restructure.NEVER).queueForPurge();
	this.map.getMockReference(3, Restructure.NEVER).queueForPurge();
	assertThat(this.map.getReference(1, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(2), is("2"));
	assertThat(this.map.getReference(3, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(4), is("4"));
	assertThat(this.map.get(5), is("5"));
}
 
Example #6
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPergeOnPut() throws Exception {
	this.map = new TestWeakConcurrentCache<Integer, String>(1, 0.75f, 1);
	for (int i = 1; i <= 5; i++) {
		this.map.put(i, String.valueOf(i));
	}
	this.map.getMockReference(1, Restructure.NEVER).queueForPurge();
	this.map.getMockReference(3, Restructure.NEVER).queueForPurge();
	this.map.put(1, "1");
	assertThat(this.map.get(1), is("1"));
	assertThat(this.map.get(2), is("2"));
	assertThat(this.map.getReference(3, Restructure.WHEN_NECESSARY), is(nullValue()));
	assertThat(this.map.get(4), is("4"));
	assertThat(this.map.get(5), is("5"));
}
 
Example #7
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public MockReference<K, V> getMockReference(K key, Restructure restructure) {
	return (MockReference<K, V>) super.getReference(key, restructure);
}
 
Example #8
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
public MockReference<K, V> getMockReference(K key, Restructure restructure) {
	return (MockReference<K, V>) super.getReference(key, restructure);
}
 
Example #9
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public MockReference<K, V> getMockReference(K key, Restructure restructure) {
	return (MockReference<K, V>) super.getReference(key, restructure);
}