Pregunta

I am developing an application which makes use of JCS. i do know how to retrive the data from the catch when searchkey is a complete string. I need to implement max-match search in JCS.

For example : cache contains following data.

  • book number | book title
  • 123 | EJB
  • 321 | Head First Java
  • 121 | Jsp and servlets
  • 111 | Ant scripting

when user inputs just 1 for book number it should fetch all the book title with book number starting with 1. i.e it should list

  • EJB
  • Jsp and servlets
  • Ant scripting

It is the kind of search we do in sql using 'like and %' .

Kindly help me.

Thanks in advance!!!

¿Fue útil?

Solución

You should be able to to do something like this:

JCSAdminBean admin = new JCSAdminBean();
LinkedList<CacheElementInfo> cacheElements = admin.buildElementInfo("myCache");
for (CacheElementInfo e : cacheElements) {
    if (e.getKey().startsWith("1")) {
        //do something.. store it in a list?
    }
}

Try it out and let me know if that works for you.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top