àCache/Buffer is a tempery memory that holds
results or data and uses that data or results across the multiple same request
given by application
àThe Process of
storing results in cache/buffer and using that result across the multiple
requests or execution of the application is called caching/buffering
àIn Client-Server
application if caching is enabled at client-side it reduces network roundtrips
between client and server application
àEvery Browser window
contains buffer and stores request related response. Response Result the buffer
of browser window reduces network roundtrips between browser window and webserver across the multiple
same requests given by browser window
àHibernate supports
two levels of caching
1.First level caching /
L1 caching ( At Hibernate Session Object)
2.Second Level
caching/L2 Caching(At Hibernate Session Factory Object)
First level cache is built-in cache. Second Level cache
is Configurable Cache.
i.e second level cache will be enable when programmer
configures it manually.
(a1-->g1) is first request operations
(a2-->c2) second request operations
(a3-->c3) third request operations
State 1:
A1-->Session Object uses initial request
B1-->Searched for that query result in level1 cache
of session object 1(Not available)
C1-->searches for query result in level2 cache(not
available)
D1-->Hibernate application interacts with database
software and gets query execution related results
E1-->Hibernate software registers the results in
level2 cache
F1-->Hibernate software also registers the result in
level1 cache of session object1
G1-->Session object1 uses the result to application
State 2:
A2-->Session Object2 gives same request once again
B2-->searches for result in level 1 cache of session
object1(available)
C2-->Session object1 collects the result from its own
level 1 cache and passes to client application
State 3:
A3-->Session object2 of same client application gives
same request to database software
B3-->Searches for the result in level1 cache of
session object2(not available)
C3-->Searches for the result in level2
cache(available)
D3-->Collects the result from level2 cache and
registers with level 1 cache of session object2
E3-->Session Object 2 gives the result to client
application
Results in level1,level2 cache will be stored in the
form of hibernate POJO class object
The result of level1 cache and level2 cache will be
updated automatically at regular intervals
Cache
Implementations
Caches are complicated pieces of software, and the
market offers quite a number of choices both open source and commercial.
Hibernate follows these open-source softwares
•EHCache(org.hibernate..cache.EhCacheProvider)
•OSCache(org.hibernate.cache.OSCacheProvider)
•SwarmCache(org.hibernate.cache.SwarmCacheProvider)
•Jboss TreeCache(org.hibernate.cache.TreeCacheProvider)
Cache
Configurations:
<hibernate-configuration>
<session-factory>
……
<property name=“hibernate.cache.provider_class”> org.hibernate..cache.EhCacheProvider</property>
….
</hibernate-configuration>
No comments:
Post a Comment