Should work, though perhaps going to the datastore for each
back/forward button press might be overkill. Retrieving it from a
cache, like ehcache, allows you to set an expiry on the data, keep it
thread safe and even memory safe (i.e. let ehcache throw away the
objects when memory is tight, or let it write to disk if not used for
a while).

AFAIK there are no examples on the web utilizing ehcache and wicket
specifically. Just use a plain ehcache example, and access the cache
store in a loadable detacheble model, or possibly even in your service
method.

Martijn

On Wed, Mar 9, 2011 at 1:48 PM, robert.mcguinness
<robert.mcguinness....@gmail.com> wrote:
> Martijn,
>
> Wouldn't this be a safe way to cache a list at the expense of memory (using
> transient)?   In a lot of my projects I have to do some aggregation of the
> results from multiple data stores that are slow even with the caching layer.
>
>
> private class SomeDataProvider extends SortableDataProvider {
>
>                /* cache the page results but don't serialize them to session 
> or disk */
>                private transient SearchResults searchResults;
>
>                private static final long serialVersionUID = 1L;
>                private SortParam sortParam;
>
>                public SomeDataProvider () {}
>
>                @Override
>                public int size() {
>
>                        /*
>                         * if null (back button/forward button case) rebuild 
> the results using
> the search parmas that are stored with page
>                         */
>                        if (searchResults == null) {
>
>                                searchResults = 
> searchService.findSomeStuff(serializableSearchParams);
>                        }
>
>                        return searchResults.size();;
>                }
>
>                @Override
>                public IModel model(Object object) {
>                        return new 
> SearchHitModel(object).setShouldDetach(false);
>                }
>
>                @Override
>                public Iterator iterator(int first, int count) {
>
>                        SortParam sp = getSort();
>
>                        // only sort results when the sort command changes
>                        if (!sortParam.equals(sp)) {
>                                Sorter sorter = new Sorter(sp.getProperty(), 
> sp.isAscending());
>                                
> Collections.sort(searchResults.getSearchResultList(), sorter);
>                                sortParam = sp;
>                        }
>
>                        return searchResults.getPagedResults(first, 
> count).iterator();
>                }
>
>        }
>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/Storing-ArrayList-with-over-10000-objects-tp3343442p3343499.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to