SlideShare una empresa de Scribd logo
1 de 31
Alachisoft
.NET Performance Solutions

How to Handle Relational Data
in a Distributed Cache

Iqbal Khan
iqbal@alachisoft.com Ph: +1 (925) 236-2125
www.alachisoft.com

1
Alachisoft

Following Applications Need Scalability
1.

ASP.NET Apps


2.

WCF & .NET Web Services


3.

To quickly process very large amounts of data thru distribution

Grid Computing Apps


5.

To handle millions of requests

Big Data Apps


4.

To handle millions of users

To process very large computations thru distribution

Other .NET Server Apps


NCache

To handle millions of requests
www.alachisoft.com

2
Alachisoft

Data Storage is Scalability Bottleneck
ASP.NET/WCF Example

App Database

ASP.NET/WCF Servers

Database Servers
Data Access

Scale Web Farm

Web Clients

Http Calls

...
NCache

Load Balancer

www.alachisoft.com

ASP.NET Session
Storage

3
Alachisoft

The Solution

Scalable In-Memory Distributed Cache

NCache
NCache

www.alachisoft.com

4
Alachisoft

What is an In-Memory Distributed Cache?
1.

Cluster of multiple inexpensive cache servers


2.

Synchronizes cache updates across all cache servers


3.

Cache updates are immediately visible from all cache servers

Linearly scales transaction & memory capacity


4.

Pools their memory and CPU into one logical capacity

Just add more cache servers to grow capacity

Replicates data for reliability


NCache

Intelligent replication without compromising performance & scalability

www.alachisoft.com

5
Alachisoft

NCache: In-Memory Distributed Cache
ASP.NET Web Apps

WCF Web Services

Grid Computing Apps
(.NET)

.NET Server Apps

Distributed Cache Cluster
Memory pooled from all cache servers

Scale Horizontally
Windows 2008/2012 (64-bit)

Filesystem

NCache

Database Servers

www.alachisoft.com

Mainframe

6
Alachisoft

What Data to Cache?
1.

Reference Data


2.

Transactional Data


3.

Does not change very frequently (but is not static)

Changes frequently (as frequently as in a few seconds)

Most Cached Data is Relational


NCache

Comes from relational databases

www.alachisoft.com

7
Alachisoft

Challenge: Cache versus Relational Data


Cache provides a Hashtable-like interface





Each item is separate and has a “key” and a “value”.
“Value” is usually an “object”

Relational data has relationships between entities


NCache

This is a challenge for your application

www.alachisoft.com

8
Alachisoft

Peek into Caching API


Read from the Cache






Add to the Cache






object obj = cache.Get(“myKey”);
object obj = cache[“myKey”];
bool isPresent = cache.Contains(“myKey”);

cache.Add(“myKey”, obj);
cache.Insert(“myKey”, obj);
cache[“myKey”] = obj;

Remove from the Cache


NCache

object obj = cache.Remove(“myKey”);

www.alachisoft.com

9
Alachisoft

First Step: Use CacheDependency


Lets you manage relationships in the cache




One cached item depends on another




A depends on B and B depends on C. Change in C triggers both A & B

Feature introduced by ASP.NET Cache




If target cached item updated/removed, dependent automatically removed

Cascaded dependencies possible




Cache keeps track of a one-way “dependency” between cached items

Key based dependency is our focus here

NCache also provides it

NCache

www.alachisoft.com

10
Alachisoft

Second Step: Use Object Relational Mapping


Benefits of O/R Mapping





Benefits of O/R Mapping Tools






Cut down development time
Improve code quality in persistence & domain objects
Simplifies programming. No need to directly use ADO.NET

Which O/R Mapping Tools to Use?





Simplifies programming by mapping domain objects to data model
Promotes code reuse of persistence and domain objects

Entity Framework (Microsoft)
NHibernate (Open Source)

At Least Map Domain Objects to Database




NCache

Map to database entities
Capture relationships in these objects
Transform DataReader or DataTable into domain objects

www.alachisoft.com

11
Alachisoft

Mapping Domain Objects to Database
Data Model

NCache

www.alachisoft.com

12
Alachisoft

What is a Primary Object?


It is a domain object




Starting point for the application





Mapped to a table in the database

Application fetches this objects first
All other objects fetched in relation to this object

All other objects fetched in relation to this object


NCache

One-to-many and many-to-one relationships

www.alachisoft.com

13
Alachisoft

Mapping Domain Objects to Database

NCache

www.alachisoft.com

14
Alachisoft

1-1/n-1 Relationships in Distributed Cache


Strategy 1: cache related object with primary object



Strategy 2: cache related object separately

NCache

www.alachisoft.com

15
Alachisoft

1-1/n-1 Relationships in Distributed Cache
Cache related object with primary object

NCache

www.alachisoft.com

16
Alachisoft

1-1/n-1 Relationships in Distributed Cache
Cache related object separately

NCache

www.alachisoft.com

17
Alachisoft

1-n Relationships in Distributed Cache


Strategy 1: cache related objects collection with primary object




Strategy 2: cache related objects separately separately




Cache entire collection as part of the primary object

Cache entire collection as one item but separately

Strategy 3: cache related objects from collections separately


NCache

Cache each item of the collection separately

www.alachisoft.com

18
Alachisoft

1-n Relationships in Distributed Cache
Cache related object collection separately

NCache

www.alachisoft.com

19
Alachisoft

1-n Relationships in Distributed Cache
Cache each object in related collection separately

NCache

www.alachisoft.com

20
Alachisoft

m-n Relationships in Distributed Cache


Many-to-many relationships don’t exist in domain objects



Instead, represented by two one-to-many relationships




E.g. Customer->Orders and Product->Orders

Intermediary object contains many-to-one references


NCache

E.g. Order has a reference to Customer and Product

www.alachisoft.com

21
Alachisoft

Handling Collections in Distributed Cache


Scenario 1: cache entire collection as one item



Scenario 2: cache each collection item separately

NCache

www.alachisoft.com

22
Alachisoft

Handling Collections in Distributed Cache
Cache entire collection as one item

NCache

www.alachisoft.com

23
Alachisoft

Handling Collections in Distributed Cache
Cache each collection item separately

NCache

www.alachisoft.com

24
Alachisoft

Hands on Demo

NCache

www.alachisoft.com

25
Alachisoft

Some Object Caching Features


Expirations






Locking (Pessimistic & Optimistic)





Lock/Unlock for pessimistic locking (writer-lock)
Object versioning for optimistic locking (reader-lock)

Bulk Operations




Absolute-time + idle-time
Auto-reload data on expiration (if read-thru enabled)

Bulk Get, Add, Insert, and Remove

Async Operations


NCache

Async Add, Insert, and Remove

www.alachisoft.com

26
Alachisoft

Synchronize Cache with Data Sources


Synchronize with Relational Databases (SQL, Oracle, etc.)







SqlDependency
OracleDependency
DbDependency

Synchronize with non-Relational Data Sources



NCache

File based Cache Dependency
Custom Cache Dependency

www.alachisoft.com

27
Alachisoft

Data Grouping in the Cache


Group/Subgroup



Tags



Named Tags

NCache

www.alachisoft.com

28
Alachisoft

Searching the Cache


Parallel Queries with Object Query Language (OQL)




Parallel LINQ Queries




SQL-like query language to search cache based on object attributes

Standard LINQ queries can search the cache

Indexing Object Attributes for Querying


NCache

Create indexes on object attributes to speed up queries

www.alachisoft.com

29
Alachisoft

Some Other Features


NHibernate L2 Cache Provider




Entity Framework L2 Cache




Plug into NHibernate application without any code change

Plug into Entity Framework application without any code change

Dynamic Compact Serialization



NCache

Faster and more compact then regular .NET serialization
No code writing required

www.alachisoft.com

30
Alachisoft

What to Do Next?






Find more about NCache
Download 60-day Trial
Request a Personalized LIVE Demo
Read product Documentation

Thank You

NCache 4.1

www.alachisoft.com

31

Más contenido relacionado

La actualidad más candente

Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Hazelcast
 
Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?
Severalnines
 
Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...
Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...
Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...
DataStax
 

La actualidad más candente (20)

HTTP Session Replication with Oracle Coherence, GlassFish, WebLogic
HTTP Session Replication with Oracle Coherence, GlassFish, WebLogicHTTP Session Replication with Oracle Coherence, GlassFish, WebLogic
HTTP Session Replication with Oracle Coherence, GlassFish, WebLogic
 
SQL Developer for DBAs
SQL Developer for DBAsSQL Developer for DBAs
SQL Developer for DBAs
 
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
 
MySQL Cluster - Latest Developments (up to and including MySQL Cluster 7.4)
MySQL Cluster - Latest Developments (up to and including MySQL Cluster 7.4)MySQL Cluster - Latest Developments (up to and including MySQL Cluster 7.4)
MySQL Cluster - Latest Developments (up to and including MySQL Cluster 7.4)
 
Exadata MAA Best Practices
Exadata MAA Best PracticesExadata MAA Best Practices
Exadata MAA Best Practices
 
Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?
 
New life inside monolithic application
New life inside monolithic applicationNew life inside monolithic application
New life inside monolithic application
 
What to expect from MariaDB Platform X5, part 1
What to expect from MariaDB Platform X5, part 1What to expect from MariaDB Platform X5, part 1
What to expect from MariaDB Platform X5, part 1
 
Microsoft SQL Server Query Tuning
Microsoft SQL Server Query TuningMicrosoft SQL Server Query Tuning
Microsoft SQL Server Query Tuning
 
GemFire In-Memory Data Grid
GemFire In-Memory Data GridGemFire In-Memory Data Grid
GemFire In-Memory Data Grid
 
Hazelcast 3.6 Roadmap Preview
Hazelcast 3.6 Roadmap PreviewHazelcast 3.6 Roadmap Preview
Hazelcast 3.6 Roadmap Preview
 
Visualizing Kafka Security
Visualizing Kafka SecurityVisualizing Kafka Security
Visualizing Kafka Security
 
eBay Cloud CMS - QCon 2012 - http://yidb.org/
eBay Cloud CMS - QCon 2012 - http://yidb.org/eBay Cloud CMS - QCon 2012 - http://yidb.org/
eBay Cloud CMS - QCon 2012 - http://yidb.org/
 
Unified Batch & Stream Processing with Apache Samza
Unified Batch & Stream Processing with Apache SamzaUnified Batch & Stream Processing with Apache Samza
Unified Batch & Stream Processing with Apache Samza
 
Novinky v Oracle Database 18c
Novinky v Oracle Database 18cNovinky v Oracle Database 18c
Novinky v Oracle Database 18c
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Cassandra in e-commerce
Cassandra in e-commerceCassandra in e-commerce
Cassandra in e-commerce
 
Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...
Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...
Productizing a Cassandra-Based Solution (Brij Bhushan Ravat, Ericsson) | C* S...
 
How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?
 
Extreme Availability using Oracle 12c Features: Your very last system shutdown?
Extreme Availability using Oracle 12c Features: Your very last system shutdown?Extreme Availability using Oracle 12c Features: Your very last system shutdown?
Extreme Availability using Oracle 12c Features: Your very last system shutdown?
 

Similar a Handling Relational Data in a Distributed Cache

nHibernate Caching
nHibernate CachingnHibernate Caching
nHibernate Caching
Guo Albert
 
Introducing windows server_app_fabric
Introducing windows server_app_fabricIntroducing windows server_app_fabric
Introducing windows server_app_fabric
Marco Titta
 

Similar a Handling Relational Data in a Distributed Cache (20)

Four Ways to Improve ASP .NET Performance and Scalability
 Four Ways to Improve ASP .NET Performance and Scalability Four Ways to Improve ASP .NET Performance and Scalability
Four Ways to Improve ASP .NET Performance and Scalability
 
nHibernate Caching
nHibernate CachingnHibernate Caching
nHibernate Caching
 
Building High Performance and Scalable Applications Using AppFabric Cache- Im...
Building High Performance and Scalable Applications Using AppFabric Cache- Im...Building High Performance and Scalable Applications Using AppFabric Cache- Im...
Building High Performance and Scalable Applications Using AppFabric Cache- Im...
 
HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
 
HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
 
Microsoft Windows Server AppFabric
Microsoft Windows Server AppFabricMicrosoft Windows Server AppFabric
Microsoft Windows Server AppFabric
 
Architecting applications in the AWS cloud
Architecting applications in the AWS cloudArchitecting applications in the AWS cloud
Architecting applications in the AWS cloud
 
Branch office access with branch cache
Branch office access with branch cacheBranch office access with branch cache
Branch office access with branch cache
 
Introducing windows server_app_fabric
Introducing windows server_app_fabricIntroducing windows server_app_fabric
Introducing windows server_app_fabric
 
Caching By Nyros Developer
Caching By Nyros DeveloperCaching By Nyros Developer
Caching By Nyros Developer
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storage
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
 
1Z0_997_21__5_.pdf.pdf
1Z0_997_21__5_.pdf.pdf1Z0_997_21__5_.pdf.pdf
1Z0_997_21__5_.pdf.pdf
 
Ror caching
Ror cachingRor caching
Ror caching
 
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
 
Red Hat Storage Day New York - Persistent Storage for Containers
Red Hat Storage Day New York - Persistent Storage for ContainersRed Hat Storage Day New York - Persistent Storage for Containers
Red Hat Storage Day New York - Persistent Storage for Containers
 
Data Streaming with Apache Kafka & MongoDB
Data Streaming with Apache Kafka & MongoDBData Streaming with Apache Kafka & MongoDB
Data Streaming with Apache Kafka & MongoDB
 
MayaData Datastax webinar - Operating Cassandra on Kubernetes with the help ...
MayaData  Datastax webinar - Operating Cassandra on Kubernetes with the help ...MayaData  Datastax webinar - Operating Cassandra on Kubernetes with the help ...
MayaData Datastax webinar - Operating Cassandra on Kubernetes with the help ...
 
Extending Analytic Reach - From The Warehouse to The Data Lake by Mike Limcaco
Extending Analytic Reach - From The Warehouse to The Data Lake by Mike LimcacoExtending Analytic Reach - From The Warehouse to The Data Lake by Mike Limcaco
Extending Analytic Reach - From The Warehouse to The Data Lake by Mike Limcaco
 
Extending Analytic Reach
Extending Analytic ReachExtending Analytic Reach
Extending Analytic Reach
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Handling Relational Data in a Distributed Cache

  • 1. Alachisoft .NET Performance Solutions How to Handle Relational Data in a Distributed Cache Iqbal Khan iqbal@alachisoft.com Ph: +1 (925) 236-2125 www.alachisoft.com 1
  • 2. Alachisoft Following Applications Need Scalability 1. ASP.NET Apps  2. WCF & .NET Web Services  3. To quickly process very large amounts of data thru distribution Grid Computing Apps  5. To handle millions of requests Big Data Apps  4. To handle millions of users To process very large computations thru distribution Other .NET Server Apps  NCache To handle millions of requests www.alachisoft.com 2
  • 3. Alachisoft Data Storage is Scalability Bottleneck ASP.NET/WCF Example App Database ASP.NET/WCF Servers Database Servers Data Access Scale Web Farm Web Clients Http Calls ... NCache Load Balancer www.alachisoft.com ASP.NET Session Storage 3
  • 4. Alachisoft The Solution Scalable In-Memory Distributed Cache NCache NCache www.alachisoft.com 4
  • 5. Alachisoft What is an In-Memory Distributed Cache? 1. Cluster of multiple inexpensive cache servers  2. Synchronizes cache updates across all cache servers  3. Cache updates are immediately visible from all cache servers Linearly scales transaction & memory capacity  4. Pools their memory and CPU into one logical capacity Just add more cache servers to grow capacity Replicates data for reliability  NCache Intelligent replication without compromising performance & scalability www.alachisoft.com 5
  • 6. Alachisoft NCache: In-Memory Distributed Cache ASP.NET Web Apps WCF Web Services Grid Computing Apps (.NET) .NET Server Apps Distributed Cache Cluster Memory pooled from all cache servers Scale Horizontally Windows 2008/2012 (64-bit) Filesystem NCache Database Servers www.alachisoft.com Mainframe 6
  • 7. Alachisoft What Data to Cache? 1. Reference Data  2. Transactional Data  3. Does not change very frequently (but is not static) Changes frequently (as frequently as in a few seconds) Most Cached Data is Relational  NCache Comes from relational databases www.alachisoft.com 7
  • 8. Alachisoft Challenge: Cache versus Relational Data  Cache provides a Hashtable-like interface    Each item is separate and has a “key” and a “value”. “Value” is usually an “object” Relational data has relationships between entities  NCache This is a challenge for your application www.alachisoft.com 8
  • 9. Alachisoft Peek into Caching API  Read from the Cache     Add to the Cache     object obj = cache.Get(“myKey”); object obj = cache[“myKey”]; bool isPresent = cache.Contains(“myKey”); cache.Add(“myKey”, obj); cache.Insert(“myKey”, obj); cache[“myKey”] = obj; Remove from the Cache  NCache object obj = cache.Remove(“myKey”); www.alachisoft.com 9
  • 10. Alachisoft First Step: Use CacheDependency  Lets you manage relationships in the cache   One cached item depends on another   A depends on B and B depends on C. Change in C triggers both A & B Feature introduced by ASP.NET Cache   If target cached item updated/removed, dependent automatically removed Cascaded dependencies possible   Cache keeps track of a one-way “dependency” between cached items Key based dependency is our focus here NCache also provides it NCache www.alachisoft.com 10
  • 11. Alachisoft Second Step: Use Object Relational Mapping  Benefits of O/R Mapping    Benefits of O/R Mapping Tools     Cut down development time Improve code quality in persistence & domain objects Simplifies programming. No need to directly use ADO.NET Which O/R Mapping Tools to Use?    Simplifies programming by mapping domain objects to data model Promotes code reuse of persistence and domain objects Entity Framework (Microsoft) NHibernate (Open Source) At Least Map Domain Objects to Database    NCache Map to database entities Capture relationships in these objects Transform DataReader or DataTable into domain objects www.alachisoft.com 11
  • 12. Alachisoft Mapping Domain Objects to Database Data Model NCache www.alachisoft.com 12
  • 13. Alachisoft What is a Primary Object?  It is a domain object   Starting point for the application    Mapped to a table in the database Application fetches this objects first All other objects fetched in relation to this object All other objects fetched in relation to this object  NCache One-to-many and many-to-one relationships www.alachisoft.com 13
  • 14. Alachisoft Mapping Domain Objects to Database NCache www.alachisoft.com 14
  • 15. Alachisoft 1-1/n-1 Relationships in Distributed Cache  Strategy 1: cache related object with primary object  Strategy 2: cache related object separately NCache www.alachisoft.com 15
  • 16. Alachisoft 1-1/n-1 Relationships in Distributed Cache Cache related object with primary object NCache www.alachisoft.com 16
  • 17. Alachisoft 1-1/n-1 Relationships in Distributed Cache Cache related object separately NCache www.alachisoft.com 17
  • 18. Alachisoft 1-n Relationships in Distributed Cache  Strategy 1: cache related objects collection with primary object   Strategy 2: cache related objects separately separately   Cache entire collection as part of the primary object Cache entire collection as one item but separately Strategy 3: cache related objects from collections separately  NCache Cache each item of the collection separately www.alachisoft.com 18
  • 19. Alachisoft 1-n Relationships in Distributed Cache Cache related object collection separately NCache www.alachisoft.com 19
  • 20. Alachisoft 1-n Relationships in Distributed Cache Cache each object in related collection separately NCache www.alachisoft.com 20
  • 21. Alachisoft m-n Relationships in Distributed Cache  Many-to-many relationships don’t exist in domain objects  Instead, represented by two one-to-many relationships   E.g. Customer->Orders and Product->Orders Intermediary object contains many-to-one references  NCache E.g. Order has a reference to Customer and Product www.alachisoft.com 21
  • 22. Alachisoft Handling Collections in Distributed Cache  Scenario 1: cache entire collection as one item  Scenario 2: cache each collection item separately NCache www.alachisoft.com 22
  • 23. Alachisoft Handling Collections in Distributed Cache Cache entire collection as one item NCache www.alachisoft.com 23
  • 24. Alachisoft Handling Collections in Distributed Cache Cache each collection item separately NCache www.alachisoft.com 24
  • 26. Alachisoft Some Object Caching Features  Expirations    Locking (Pessimistic & Optimistic)    Lock/Unlock for pessimistic locking (writer-lock) Object versioning for optimistic locking (reader-lock) Bulk Operations   Absolute-time + idle-time Auto-reload data on expiration (if read-thru enabled) Bulk Get, Add, Insert, and Remove Async Operations  NCache Async Add, Insert, and Remove www.alachisoft.com 26
  • 27. Alachisoft Synchronize Cache with Data Sources  Synchronize with Relational Databases (SQL, Oracle, etc.)     SqlDependency OracleDependency DbDependency Synchronize with non-Relational Data Sources   NCache File based Cache Dependency Custom Cache Dependency www.alachisoft.com 27
  • 28. Alachisoft Data Grouping in the Cache  Group/Subgroup  Tags  Named Tags NCache www.alachisoft.com 28
  • 29. Alachisoft Searching the Cache  Parallel Queries with Object Query Language (OQL)   Parallel LINQ Queries   SQL-like query language to search cache based on object attributes Standard LINQ queries can search the cache Indexing Object Attributes for Querying  NCache Create indexes on object attributes to speed up queries www.alachisoft.com 29
  • 30. Alachisoft Some Other Features  NHibernate L2 Cache Provider   Entity Framework L2 Cache   Plug into NHibernate application without any code change Plug into Entity Framework application without any code change Dynamic Compact Serialization   NCache Faster and more compact then regular .NET serialization No code writing required www.alachisoft.com 30
  • 31. Alachisoft What to Do Next?     Find more about NCache Download 60-day Trial Request a Personalized LIVE Demo Read product Documentation Thank You NCache 4.1 www.alachisoft.com 31