Introduction ToIntroduction To
Shivansh Srivastava
Software Consultant
Knoldus Software LLP
Shivansh Srivastava
Software Consultant
Knoldus Software LLP
AgendaAgenda
● Why NoSQL?
● What is Couchbase?
● Why Couchbase?
● Basic CRUD operations.
● Let's code
● Why NoSQL?
● What is Couchbase?
● Why Couchbase?
● Basic CRUD operations.
● Let's code
WHYWHY
Why NoSql..??Why NoSql..??
Why NoSql..??Why NoSql..??
● Flexibility:
Schema flexibility attracts developers.
● Scalability:
Scale size and number of concurrent user.
● Availability:
Provide different replication architectures.
● Low Operational Cost:
Open Source, Distributed Architecture
● Specialized Capabilities:
Automatic data replication, Rest Api's, Indexing features.
What is Couchbase?What is Couchbase?
➢
 Distributed NoSQL document­oriented database.
➢
 Two types of Access:
                     Key­value access.
                      Document access.
➢
 Key Features :
                    Views and Indexes.
                    Global Secondary Indexing.
                    Multidimensional Scaling.
                    N1QL Query(“Nickel”)
➢
 Distributed NoSQL document­oriented database.
➢
 Two types of Access:
                     Key­value access.
                      Document access.
➢
 Key Features :
                    Views and Indexes.
                    Global Secondary Indexing.
                    Multidimensional Scaling.
                    N1QL Query(“Nickel”)
Couchbase
Why Couchbase?Why Couchbase?
Enterprise Edition FeaturesEnterprise Edition Features
 Rack Awareness
 Encrypted administrative access
 Encrypted data access
 XDCR data encryption
 Incremental backup and restore
 Rack Awareness
 Encrypted administrative access
 Encrypted data access
 XDCR data encryption
 Incremental backup and restore
Key Features in Enterprise Edition
Installing CouchbaseInstalling Couchbase
Steps of InstallationSteps of Installation
➔ Download Couchbase from their official website.
➔ Install the package using the dpkg command as a privileged
user under sudo.
For example: sudo dpkg –i couchbase-server-enterprise_4.0.0-beta-
ubuntu14.04_amd64.deb
Setting up Couchbase Server.Setting up Couchbase Server.
 Open a browser and navigate to http://hostname:8091/ for
configuring your server.
 Click Setup.
 On the Configure Server screen, select check boxes for data,
query, and index services and click next, to start a new cluster.
 Open a browser and navigate to http://hostname:8091/ for
configuring your server.
 Click Setup.
 On the Configure Server screen, select check boxes for data,
query, and index services and click next, to start a new cluster.
Steps for Configuring Couchbase Server
➢ Sample Buckets screen:
Select bucket you want to include and then click Next.
➢
Default Bucket screen:
Click Next to accept the default values.
➢Notifications screen:
Agree to the terms and conditions, and click Next.
➢Configure Server screen:
Enter a password for the Administrator user name, and then click Next.
➢ Sample Buckets screen:
Select bucket you want to include and then click Next.
➢
Default Bucket screen:
Click Next to accept the default values.
➢Notifications screen:
Agree to the terms and conditions, and click Next.
➢Configure Server screen:
Enter a password for the Administrator user name, and then click Next.
Continued..
Finally
Succeeded..!!!!
CRUD Operations in CouchbaseCRUD Operations in Couchbase
Dependency InjectionDependency Injection
We have to inject these two dependencies for enabling the use of
couchbase in our project.
Setting up connectionSetting up connection
//Required imports
import com.couchbase.client.java.{Bucket,
CouchbaseCluster}
//Create cluster and open bucket
val cluster = CouchbaseCluster.create(“127.0.0.3”)
val bucket = cluster.openBucket(“user”)
//case class to store data in bucket
case class User(name:String, email: String)
Create and Update OperationCreate and Update Operation
<BucketObject>.upsert(Document):Document
It updates a document according to the key,and if document is not present
it creates and it returns the document itself.
Retrieve OperationRetrieve Operation
<BucketObject>.get(key:String):JsonDocument
It retrieves the Json document on the basis of the key that is passed.
Delete OperationDelete Operation
<BucketObject>.remove(key:String): JsonDocument
It removes the document from the bucket according to the user id that is
passed and returns that Json Document itself.
Thank youThank you

Couchbase training basic

Editor's Notes

  • #14 many web application want to increase application throughput, responsivenesswhere one task can make progress without waiting for all others to completewhere more than one task can make progress at same time.Concurrent program can be executed on single core machine via time slicYou may execute concurrent program in parallelOverall you play with threads