Caching Over Mybatis – Summary of Approaches
Join the DZone community and get the full member experience.
Join For FreeThis article presents a summary of the four Proof of Concepts described in the article 4 Hands-On Approaches to Improve Your Data Access Layer Implementation and contains a retrospective of the four implementations, with a comparison table of their key features.
Code for implementations can be accessed at https://github.com/ammbra/CacherPoc .
Before analyzing the results we obtained through the four implementations, I would like to remind the goal of these articles: to illustrate through usage the behavior of MyBatis cache implementations with Ehcache, Hazelcast, Memcached and OSCache. A more complex view of CacherPOC and its associates is presented below:
and the online view of the application:
I am going to detail my opinions about the four libraries, after concept's implementation.
All the used libraries (Ehcache, OSCache, Memcached and Hazelcast) support in memory data management, transactions and have the following attributes:
- atomicity
- consistency
- isolation
- durability (durability of data handling as ACID integrity model specifies)
- horizontal scalable
- automatic deletion after expiration
- embedable
- open source
- function on cross-platform operating systems
Also, let's investigate what differentiate them in terms of features:
Characteristic |
Ehcache |
Hazelcast |
Memcached |
OSCache |
The language the software is written in |
Java |
C#, Java, .net, C++ |
C# |
Java |
Database model |
Key-Value Distributed data structure NoSQL Schema-less |
Key-Value Distributed data structure NoSQL Schema-less Publish/Subscribe |
Key-Value |
Key-Value |
Integrity model |
ACID |
ACID MVCC Serializable |
ACID |
ACID |
Maximum size of a single value |
8GB |
10MB |
1MB |
? |
Conditional entry updates |
Yes |
Yes |
No |
No |
Composite key |
Yes |
Yes |
No |
No |
Locking model |
Optimistic Locking |
Optimistic Locking Pessimistic Locking Distributed Locking |
Lock Free Model |
? |
Data Storage |
Volatile Memory File System |
Volatile Memory Relational DB |
Volatile Memory |
Volatile Memory |
Backup Functionality |
Good |
Good |
Basic |
? |
Second level caching |
Yes |
Yes |
No |
No |
Cloud platform support |
? |
Amazon EC2 |
? |
? |
Map and reduce |
? |
Yes |
No |
? |
? - could not be determined
Based on features list, we can choose a caching implementation. But the most important evidence came from CacherPOC project: the results obtained when Amdhal's law was applied.
Amdhal's law is
where P is proportion speed up and S is speed up.
Below are listed the results obtained by :
- Ehcache implementation : 2 times system speedup
- Hazelcast implementation : 1.96 times system speedup
- Memcached implementation: 2.083 times system speedup
- Oscache implementation: 2.028 times system speedup
The results obtained show Memcached as the winner of caching over mybatis competition, but do not forget that it was tested a simple select; have in mind that complex operation might show another framework to be more suitable for caching over MyBatis. My recommendation would be: download CacherPOC, modify with the complex operations that you should test and check your own system speedup by using Amdhal's law. CacherPOC represents the base of complex future system tests.
Learn more from:
Opinions expressed by DZone contributors are their own.
Trending
-
Deploying Smart Contract on Ethereum Blockchain
-
Strategies for Reducing Total Cost of Ownership (TCO) For Integration Solutions
-
What ChatGPT Needs Is Context
-
Integrating AWS With Salesforce Using Terraform
Comments