Skip to content

Commit 082dd44

Browse files
committed
Added a comment that includes how to config via xml
1 parent e1eb3e7 commit 082dd44

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/org/sharrissf/sample/EhcacheSearchPlaying.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ private void initializeCache() {
4444
// Create attributes on the stuff we want to be able to search on.
4545

4646
// You can use an expression for getting at the value to be indexed on a cache or you can code your own
47+
48+
// Expression
4749
SearchAttribute sa = new SearchAttribute();
4850
sa.setExpression("value.getAge()");
4951
sa.setName("age");
5052
cacheConfig.addSearchAttribute(sa);
5153

54+
// Coding your own
5255
sa = new SearchAttribute();
5356
sa.className("org.sharrissf.sample.EhcacheSearchPlaying$NameAttributeExtractor");
5457
sa.setName("name");
@@ -64,6 +67,16 @@ private void initializeCache() {
6467
sa.setName("state");
6568
cacheConfig.addSearchAttribute(sa);
6669

70+
// If you want to initialize it via ehcache.xml it would look like this
71+
// <cache name="test" maxElementsInMemory="0" eternal="true" overflowToDisk="false">
72+
// <searchAttribute name="age" expression="value.getAge()"/>
73+
// <searchAttribute name="name" class="org.sharrissf.sample.EhcacheSearchPlaying$NameAttributeExtractor"/>
74+
// <searchAttribute name="gender" expression="value.getGender()"/>
75+
// <searchAttribute name="state" expression="value.getState()"/>
76+
// </cache>
77+
78+
79+
6780
cacheManagerConfig.addCache(cacheConfig);
6881

6982
cacheManager = new CacheManager(cacheManagerConfig);

0 commit comments

Comments
 (0)