Skip to content

Commit ecedfd7

Browse files
committed
added use off orderBy and max
1 parent 082dd44 commit ecedfd7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.sf.ehcache.config.Configuration;
1010
import net.sf.ehcache.config.SearchAttribute;
1111
import net.sf.ehcache.search.Attribute;
12+
import net.sf.ehcache.search.Direction;
1213
import net.sf.ehcache.search.Query;
1314
import net.sf.ehcache.search.Result;
1415
import net.sf.ehcache.search.Results;
@@ -69,14 +70,12 @@ private void initializeCache() {
6970

7071
// If you want to initialize it via ehcache.xml it would look like this
7172
// <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()"/>
73+
// <searchAttribute name="age" expression="value.getAge()"/>
74+
// <searchAttribute name="name" class="org.sharrissf.sample.EhcacheSearchPlaying$NameAttributeExtractor"/>
75+
// <searchAttribute name="gender" expression="value.getGender()"/>
76+
// <searchAttribute name="state" expression="value.getState()"/>
7677
// </cache>
7778

78-
79-
8079
cacheManagerConfig.addCache(cacheConfig);
8180

8281
cacheManager = new CacheManager(cacheManagerConfig);
@@ -94,7 +93,7 @@ public void runTests() throws IOException {
9493
Query query = cache.createQuery();
9594
query.includeKeys();
9695
query.includeValues();
97-
query.add(new And(name.like("Ari*"), gender.eq(Gender.MALE)));
96+
query.add(new And(name.like("Ari*"), gender.eq(Gender.MALE))).addOrder(age, Direction.ASCENDING).maxResults(10);
9897

9998
long t = System.currentTimeMillis();
10099
System.out.println("Searching for all Person's who's name start with Ari and are Male:");
@@ -167,7 +166,8 @@ public static void main(String[] args) throws IOException {
167166
public static class NameAttributeExtractor implements AttributeExtractor {
168167

169168
/**
170-
*
169+
* Implementing the AttributeExtractor Interface and passing it in allows you to create very efficient and specific attribute
170+
* extraction for performance sensative code
171171
*/
172172
private static final long serialVersionUID = 1L;
173173

0 commit comments

Comments
 (0)