mainstringargs
mainstringargs

Reputation: 13923

Caching solutions and Querying

Are there any in-memory/caching solutions for java that allow for a form of Querying for specific attributes of objects in the Cache?

I realize this is something that a full blown database would be used for, but I want to be able to have the speed/performance of a cache with the Querying ability of a database.

Upvotes: 8

Views: 4328

Answers (7)

Sanne
Sanne

Reputation: 6107

Nowadays the answer should be updated to Infinispan, the successor of JBoss Cache and having much improved Search technology.

Upvotes: 3

John Ellinwood
John Ellinwood

Reputation: 14531

Terracotta or GBeans or POJOCache

Upvotes: 3

jli_123
jli_123

Reputation: 215

You might want to check out this library:

http://casperdatasets.googlecode.com

this is a dataset technology. it supports tabular data (either from a database or constructed in code), and you can then construct queries and filters against the dataset (and sort), all in-memory. its fast and easy-to-use. MOST IMPORTANTLY, you can perform queries against ANY column or attribute on the dataset.

Upvotes: 0

mhaller
mhaller

Reputation: 14222

Another idea is to use Lucene and a RAMDirectory implementation of Directory to index what you put into your cache. That way, you can query using all the search engine query features which Lucene provides.

In your case, you will probably index the relevant properties of your objects as-is (without using an Analyzer) and query using a boolean equality operator.

Lucene is very lightweight, performant, thread-safe and memory consumption is low.

Upvotes: 0

Steve Claridge
Steve Claridge

Reputation: 11100

JBoss Cache has search functionality. It's called JBossCacheSearchable. From the site:

This is the integration package between JBoss Cache and Hibernate Search.

The goal is to add search capabilities to JBoss Cache. We achieve this by using Hibernate Search to index user objects as they are added to the cache and modified. The cache is queried by passing in a valid Apache Lucene query which is then used to search through the indexes and retrieve matching objects from the cache.

Main JBoss Cache page: http://www.jboss.org/jbosscache/

JBossCacheSearch: http://www.jboss.org/community/docs/DOC-10286

Upvotes: 4

ordnungswidrig
ordnungswidrig

Reputation: 3196

Look at db4oat rather lightweight java object database. You can even query the data using regular java code:

List students = database.query( new Predicate(){
      public boolean match(Student student){
        return student.getAge() < 20
          && student.getGrade().equals(gradeA);}})

(From this article).

Upvotes: 1

Eric Petroelje
Eric Petroelje

Reputation: 60559

At first, HSQLDB came to mind, but that's an in-memory relational database rather than an object database. Might want to look at this list. There's a few object databases there, one of which might meet your needs.

Upvotes: 2

Related Questions