Tuesday, September 29, 2009
Spymemcached Optimizations Followup
If you combine the latest spymemcached RC release, with memcached 1.4 and the new binary protocol you should see significant performance increases. As Dustin didn't change anything about the spymemcached API it should be a drop in upgrade for you.
spymemcached Optimizations - Dustin Sallings
hibernate-memcached
Enjoy!
Monday, August 10, 2009
Hibernate-memcached 1.2.1 Released
You can download the 1.2.1 from the site, or just update your maven pom.
http://code.google.com/p/hibernate-memcached/
Enjoy!
Friday, July 17, 2009
Hibernate-memcached 1.2 Released
The 1.2 release updates the Maven dependencies to spymemcached 2.3.1, which includes some bug fixes and reduces the dependencies by one jar (spy.jar is gone). The main purpose of the hibernate-memcached release is to add support for the new binary protocol released with memcached 1.4. Previous versions of memcached only supported the ascii protocol. This has always performed well in it's own right; but the binary protocol reduces CPU compute time and can decrease response time as well.
The hibernate-memcached release also includes a minor tweak to use getMulti in Memcached when DogpilePrevention is enabled. Not a big deal, but someone pointed out an opportunity for it; so I added it.
You can download hibernate-memcached here. Or you can setup your maven project by following these instructions. As always, the source is available via github.
Enjoy!
-Ray Krueger
Sunday, December 07, 2008
Hibernate-memcached 1.1.0 Released!
- Support for the Whalin memcached client
- New Key strategies: Md5KeyStrategy, Sha1KeyStrategy for reducing the length of keys
- Better Exception handling during cache failure scenarios
This is the first release after moving the source to github.
I need to do some wiki work to get documentation up for how to enable and configure the Whalin/Danga memcached client. I hope to get to that some time this week.
The new KeyStrategy implementations for Md5 and Sha1 are there to reduce the size of the keys. Raymond He emailed me to point out that the obnoxiously long keys that Hibernate generates take up a lot of memory in memcached. Many records + ~250 char keys = a lot of wasted space. The new Md5 and Sha1 keys strategies simply take the fully qualified key name generated by hibernate-memcached and hash them up to take a lot less space.
The improved exception handling revolves around the addition of a new MemcachedExceptionHandler interface and a default LoggingMemcacheExceptionHandler implementation. Essentially the Spy and Danga memcached clients are wrapped up to eat any exception that comes out of them. There's really no reason for the cache layer to throw exceptions at Hibernate. Errors are logged as Errors, and a null is returned.
Enjoy!
Sunday, October 05, 2008
Hibernate-memcached moved to github
git svn --authors-file=/home/ray/.authors clone http://hibernate-memcached.googlecode.com/svn/tags/hibernate-memcached-1.0 hibernate-memcached
cd hibernate-memcached
git remote add origin git@github.com:raykrueger/hibernate-memcached.git
git push -f origin master
git tag hibernate-memcached-1.0
git push --tags
I probably could have tagged it initially, but I didn't think of it :P
Wednesday, August 20, 2008
Hibernate-memcached 1.0 released into the wild!
If you have any questions or comments please drop a line here or even use the hibernate-memcached Google group.
So, what next?
Tuesday, August 19, 2008
Hibernate 3.3 and Hibernate-memcached
I spent some time looking over the new Cache SPI released in Hibernate 3.3.0.GA. Definitely a much more in-depth API compared to the old CacheProvider/Cache interfaces. Following the new interfaces (RegionFactory, Region) you can be much more aware as to your specific responsibilities in the caching system.
I have tested that hibernate-memcached remains compatible with hibernate-3.3.0 and everything looks fine. I am going to hold off on implementing a RegionFactory/Region based implementation for now and do that as a post 1.0 release. It will require some refactoring to the current code base to get it to play nice with both APIs (I'd like to stay compatible with 3.2 for a while).
So, look forward to a hibernate-memcached 1.0 release tonight, or maybe tomorrow.
P.S. Hello China! According to Google analytics, a link from javaeye.com is generating 250+ hits a day to the hibernate-memcached project site right now.
Tuesday, August 05, 2008
Hibernate-memcached in the MySQL faq
Neat!
http://dev.mysql.com/doc/refman/5.0/en/ha-memcached-faq.html
http://dev.mysql.com/doc/refman/6.0/en/ha-memcached-faq.html
Saturday, July 26, 2008
Hibernate-memcached 1.0-RC1 Released
If you have questions or problems please visit the hibernate-memcached google group.
Friday, July 11, 2008
Dogpile Prevention for Hibernate-memcached
If you're only running 2 or 3 instances of your application this really isn't a problem. If you're running 42 instances there is the risk of a "dogpile". If a frequently used item drops from the cache after it's expiration time comes up you run the risk of many instances of your application working concurrently to restore the cached data. Each instance overwriting the other instances attempt to update the cache until everyone sees the data is no longer missing. Other caching systems attempt to remedy this with locking. That's a really bad thing most of the time for scaling as you'd never want to have all the instances of your application synchronized on what one of them is doing.
To remedy this in hibernate-memcached I will follow the patterns mentioned in the article above. This new feature will go in as a configurable option that is, by default, turned off. I plan to make it configurable per cache-region so enabling it would look like hibernate.memcached.
Once I get this in and tested I plan to release a 1.0-RC1 version of hibernate-memcached.
Tuesday, June 10, 2008
Hibernate-memcached 0.6 released
hibernate-memcached at Googlecode
Saturday, May 31, 2008
Introducing hibernate-memcached
Some of you may, or may not (care), know I am a huge fan of memcached. Its combination of simplicity, elegance and performance make it fantastic choice for any real caching solution.
I've recently begun work on implementing a bridge for using memcached as a second-level cache for hibernate. The project is hosted at googlecode right now, and the code is currently available in the googlecode hosted subversion repositories. In the future I'll probably move it over to github, but subversion is much more accessible to the public at large still.
Adding hibernate-memcached to your hibernate based application is as simple as adding hibernate-memcached.jar, memcached.jar, and spy.jar to your classpath. This can also be done using Maven.
Enabling the hibernate-memcached cache is simple as adding two properties to your hibernate config.
hibernate.cache.provider_class=com.googlecode.hibernate.memcached.MemcachedCacheProvider
hibernate.memcached.servers=server1:11211 server2:11211
Property #1 tells Hibrnate to use the MemcachedCacheProvider. Property #2 tells the MemcachedClient in use what servers to use for the cache. It really is as simple as that.
There are many other configuration properties available to configure things like the default and per-region cache times, operation timeout, hash algorithm to use, and what key strategy to use.
The hibernate-memcached cache is working great for both individual entity caching and query caching. I currently have a lot of work to do around getting documentation up on the googlecode site. It is ready to play with and easy to setup, if anyone out there has the time to check out; please do! If you run into any questions or problems you can post them on the hibernate-memached google group, or open an issue at googlecode.
Thursday, March 13, 2008
Hibernate and Memcached
The Hibernate second level cache is used to cache items between session invocations. Hibernate always uses it's session as a first level cache, but if you want to avoid database hits between sessions you need a second level cache. If you want these caches to stay in synch between several instances of your application, you need a distributed second level cache.
Memcached is a fantastically fast distributed cache, so why not use that? Once I build a jar of the hibernate-memcached project you'll be able to include it in your application and tell Hibernate to use it. Telling Hibernate to use it means adding the cache_provider property to your hibernate.cfg.xml, or your Spring LocalSessionFactoryBean if you're using that. The hiberante.cfg.xml looks like this...
<hibernate-configuration>
<session-factory>
<property name="hibernate.cache.provider_class">com.googlecode.hibernate.memcached.MemcachedCacheProvider</property>
<mapping class="com.yadda.yadda.Something"/>
</session-factory>
</hibernate-configuration>
Then, in your mappings you tell Hibernate that you want instances of your persistent objects to be cached, or collections from relation ships to be cached. Once Hibernate knows what you want cached you can watch it pump stuff into memcached, which is good clean geeky fun. Fire up memcahed (on windows or linux) using the -vv command line option to make it run "very verbose". You can see it storing and responding for each operation taken.
You can play with the code straight out of subversion at google code. It will actually work and cache stuff, but it is currently hardcoded to look only at localhost:11211 for a memcached instance. I'll get around to making it configurable. To build the code you'll need Maven2. I highly recommend using Don Brown's no-suck port of maven2 actually.
More to come...