How to make overflow the cache configured using Ehcache? - ehcache

Can anyone please share the example for make the cache overflow which uses setMaxEntries method in Ehcache?

Related

Is Spring Cache clusterable?

I've got an application that uses Spring Cache (Ehcache), but now we need to add a 2nd node (same application). Can the cache be shared between the nodes or each with their own instance but synched?
Or do I need to look at a different solution?
Thanks.
That depends on your cache implementation - not on Spring, which only provides an abstract caching API. You are using EhCache as your caching implementation, which comes with a Terracotta server for basic clustering support and is open source. See http://www.ehcache.org/documentation/3.1/clustered-cache.html#clustering-concepts for more details

Where are spring tutorials without spring-boot? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
All the tutorials on spring.io are now all spring-boot centric. I'm not interested in converting existing projects to boot, and am not particularly interested in using boot for new projects, the "Takes an opinionated view of building Spring applications..." project statement isn't particularly encouraging.
Given this, I'm wondering where all the tutorials are for using spring without boot. Sure, the docs are great but those old tutorials were great.
Hopefully, with Google help, it is easy to find the excellent tutorials from mkyong. The reference manual (ok, not a tutorial) contains also a good deal of examples.
But you are right, it is easy to find javadoc and reference manuals for older Spring versions, but I could not find any tutorial on spring.io without spring-boot.
Edit (per m4rtin's comment) :
For a true beginner that would want to avoid spring-boot (want to deploy to a real container for example), they can be used alone. They can be used also as a way to skip the spring-boot part along with a more up to date tutorial from spring.io. I mean : spring-boot is just a way to automagically build a skeletal application including application contextes, and it is used for that in recent tutorials. But you can always create the skeletal application without spring-boot (with the use of the older mkyong tutorials) and then add the other components to follow a newer tutorial. Of course, it is a more advanced use, but it is the way I did for recently try some parts of Spring (other than the basic framework) because I am used to my old own tomcat and do not really like boot.
Of course if you only want to try something that you will throw away as soon as completed, the right way is probably to fully follow the new tutorials and use boot.
One can never please everyone.
When adding plain Spring samples people will start asking question why DataSources don't work or their activemq setup doesn't work (people usually don't takes days to figure it out, if it doesn't work < 5m a guide/project/sample is crap even if the error is their own).
The same for XML and JavaConfig for years the argument was that Spring == XML Hell (just take a look at their samples was often overheard/-read) now that is Java based config (a road that even Java EE is taking) it isn't ok either.
The Spring Boot guides allow you to focus on the core content at hand, instead of all the necessities/complexities around them. Nonetheless I do agree that some basic plain Spring Framework guides should exist. You might wan to comment on this issue

What is mean by a lightweight framework? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
What is a lightweight framework? Why it is saying that codeigniter is lightweight?
Here is a post i found on coderanch.com :
The term "lightweight" refers to the conceptual weight of a framework.
Lightweight frameworks like Spring have minimal impact to an
application. That is, it does not require as many code changes to
incorporate them into your application as does the more heavyweight
frameworks like EJB. When you create an EJB, you have to deal with
several interfaces and it is pretty clear by looking at the code that
an EJB is tightly coupled to the J2EE framework. On the other hand, a
POJO is usually blissfully unaware that it is being used in the Spring
Framework. Spring is minimally-invasive. There are also claims that it
should not be a very difficult task to take Spring out and replace it
with another similar framework.
With lightweight frameworks, you do not have to think too much about
the underlying framework because there really isn't much code to write
that explicitly ties you in with the "plumbing". On the other hand,
traditional J2EE development with EJB entails writing a lot of
"plumbing" code which weighs you down conceptually.
Hope it helps.

Advantage of using ehcahce over a static HashMap

I have always used the java singleton class for my basic caching needs.
Now the project is using ehcache and without looking deeply into source code, I am not able to figure out what was wrong with the singleton pattern.
i.e What are the benefits of using the ehcahce framework except that the caching can be done by using xml configuration and annotation without writing the boilerplate code (i.e a static HashMap)
It depends on what you need from your caching mechanism. Ehcache provides a lot of cool features, which require a lot of well designed code to do it manually:
LRU, LFU and FIFO cache eviction policies
Flexible configuration
Persistence
Replication
many more ...
I would recommend you go through them at http://ehcache.org/about/features and decide do you really need something in your project.
The most important one:
The ability to overflow to disk - this is something you don't have in normal HashMap and writing something like that is far from trivial. EhCache can function as simple to configure key-value database.
Even if you don't use overflow to disk, there's a large boilerplate to write with your own implementation. If loading the whole database would be possible, that using memory database with persistence on write and restoring on startup would be the solution. But memory is limited and you have to remove the elements from memory. But which one, based on what? Also, you must assert cache elements are not too old. Older elements should be replaced. If you need to remove elements from cache, you should start from the outdated ones. But should you do it when user requests something? It will slow down the request. Or start your own thread?
With EhCache you have the library in which all those issues are addressed and tested.
Also there is a clustered closed source version of ehcache, which allows you to have a distributed cache. That might be one reason you might want to consider using ehcache.

Can we extend Spring source code when working for a commercial app? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I always have used Spring Framework classes as-is.
However I am thinking of customizing the Spring-WS (WebService) behavior by extending its WebServiceTemplate class.
The WebServiceTemplate currently offers only 'sendAndReceive', but I want to make it do only a 'send'. And then a separate thread do a 'receive'. (This is being done to mirror existing work flow that relies on Messaging).
So I was thinking of extending the class..
What sort of things do I need to be aware of, before extending from an Open Source code, for a commercial app? Also, Am I free to use the source code and copy it as need be?
UPDATE:
Looks like Spring uses same license as Apache
http://www.apache.org/licenses/LICENSE-2.0
Spring-WS use Apache License. You are free to modify and use in commercial project. There are some restrictions (e.g., you can't use the Spring trademark), but this should be ok for most projects.

Resources