Home Database Mysql Tutorial MySQL5.6.10 NoSQL API访问方式体验

MySQL5.6.10 NoSQL API访问方式体验

Jun 07, 2016 pm 04:35 PM
api nosql experience Way access

MySQL 近期发布5.6的GA版本,其中确实有很多不错的特性值得关注和尝试。NoSQL API的支持就是其中一个比较不错的亮点,我们这就来尝试一下。详细的特性介绍可访问:http://dev.mysql.com/tech-resources/articles/mysql-5.6.html 。 从MySQL官网了解到,通过M

MySQL 近期发布5.6的GA版本,其中确实有很多不错的特性值得关注和尝试。NoSQL API的支持就是其中一个比较不错的亮点,我们这就来尝试一下。详细的特性介绍可访问:http://dev.mysql.com/tech-resources/articles/mysql-5.6.html 。

从MySQL官网了解到,通过Memcache的API即可访问MySQL的NoSQL API。

Many of the latest generation of web, cloud, social and mobile applications require fast operations against simple Key/Value pairs. At the same time, they must retain the ability to run complex queries against the same data, as well as ensure the data is protected with ACID guarantees. With the new NoSQL API for InnoDB, developers have all the benefits of a transactional RDBMS, coupled with the performance capabilities of Key/Value store.
MySQL 5.6 provides simple, key-value interaction with InnoDB data via the familiar Memcached API. Implemented via a new Memcached daemon plug-in to mysqld, the new Memcached protocol is mapped directly to the native InnoDB API and enables developers to use existing Memcached clients to bypass the expense of query parsing and go directly to InnoDB data for lookups and transactional compliant updates. The API makes it possible to re-use standard Memcached libraries and clients, while extending Memcached functionality by integrating a persistent, crash-safe, transactional database back-end. The implementation is shown here:


So does this option provide a performance benefit over SQL? Internal performance benchmarks using a customized Java application and test harness show some very promising results with a 9X improvement in overall throughput for SET/INSERT operations:

首先部署Server端的Memcache plugin集成环境。目前支持的系统为Linux, Solaris, and OS X,不支持windows。文档地址:http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-setup.html

由于我采用的tar包安装的MySQL,所以在安装memcache plugin的时候需要先安装libevent包。

1

yum install libevent

Copy after login

即可。

然后,安装libmemcached所需要的表

将插件设置成随服务启动而启动的守护插件

重启MySQL服务,安装完成。默认访问端口为11211。

下面来验证一下安装,简单的可以采用telnet的方式发送memcached命令

然后通过sql,在demo_test表中查询数据:

再通过Java代码操作一下,我们采用xmemcached作为client api。官方地址:https://code.google.com/p/xmemcached。Maven依赖:

1

2

3

4

5

<dependency>    

      <groupid>com.googlecode.xmemcached</groupid>

      <artifactid>xmemcached</artifactid>

      <version>1.4.1</version>

</dependency>

Copy after login

代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

/**

     * @param args

     * @author lihzh(OneCoder)

     * @blog http://www.coderli.com

     * @throws MemcachedException

     * @throws InterruptedException

     * @throws TimeoutException

     * @throws IOException

     * @date 2013 -3 -12 下午12:07:41

     */

    public static void main(String[] args) throws TimeoutException, InterruptedException, MemcachedException, IOException {

          MemcachedClient client = new XMemcachedClient("10.4.44.208" , 11211);

           // store a value for one hour(synchronously).

          client.set( "key", 3600, "onecoder");

           // Retrieve a value.(synchronously).

          Object someObject = client.get( "key");

           // Retrieve a value.(synchronously),operation timeout two seconds.

          someObject = client.get( "key", 2000);

          System. out.println(someObject);

    }

Copy after login

通过mysql客户端查询记录,成功存入:

这里测试的仅仅最基本的功能,如果想使用该功能,还需要做好传统数据表与memcache表的映射关系。具体可参考:http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-developing.html。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of inaccessibility after Tomcat deploys war package How to solve the problem of inaccessibility after Tomcat deploys war package Jan 13, 2024 pm 12:07 PM

How to solve the problem that Tomcat cannot successfully access the war package after deploying it requires specific code examples. As a widely used Java Web server, Tomcat allows developers to package their own developed Web applications into war files for deployment. However, sometimes we may encounter the problem of being unable to successfully access the war package after deploying it. This may be caused by incorrect configuration or other reasons. In this article, we'll provide some concrete code examples that address this dilemma. 1. Check Tomcat service

Recommended Java decompilation tools: the five most popular tools that bring the ultimate experience Recommended Java decompilation tools: the five most popular tools that bring the ultimate experience Dec 26, 2023 am 09:00 AM

Ultimate decompilation experience: Recommend the five most popular Java decompilation tools Introduction: With the development of technology, software security and intellectual property protection are becoming more and more important, and decompilation technology is an important means. This article will introduce five of the most popular Java decompilation tools, allowing you to experience the ultimate decompilation experience. 1. JD-GUI JD-GUI is an open source Java decompilation tool, which is characterized by simple operation and friendly interface. Through JD-GUI, you can reverse Java class files

How to deal with Laravel API error problems How to deal with Laravel API error problems Mar 06, 2024 pm 05:18 PM

Title: How to deal with Laravel API error problems, specific code examples are needed. When developing Laravel, API errors are often encountered. These errors may come from various reasons such as program code logic errors, database query problems, or external API request failures. How to handle these error reports is a key issue. This article will use specific code examples to demonstrate how to effectively handle Laravel API error reports. 1. Error handling in Laravel

Oracle API Usage Guide: Exploring Data Interface Technology Oracle API Usage Guide: Exploring Data Interface Technology Mar 07, 2024 am 11:12 AM

Oracle is a world-renowned database management system provider, and its API (Application Programming Interface) is a powerful tool that helps developers easily interact and integrate with Oracle databases. In this article, we will delve into the Oracle API usage guide, show readers how to utilize data interface technology during the development process, and provide specific code examples. 1.Oracle

Oracle API integration strategy analysis: achieving seamless communication between systems Oracle API integration strategy analysis: achieving seamless communication between systems Mar 07, 2024 pm 10:09 PM

OracleAPI integration strategy analysis: To achieve seamless communication between systems, specific code examples are required. In today's digital era, internal enterprise systems need to communicate with each other and share data, and OracleAPI is one of the important tools to help achieve seamless communication between systems. This article will start with the basic concepts and principles of OracleAPI, explore API integration strategies, and finally give specific code examples to help readers better understand and apply OracleAPI. 1. Basic Oracle API

Development suggestions: How to use the ThinkPHP framework for API development Development suggestions: How to use the ThinkPHP framework for API development Nov 22, 2023 pm 05:18 PM

Development suggestions: How to use the ThinkPHP framework for API development. With the continuous development of the Internet, the importance of API (Application Programming Interface) has become increasingly prominent. API is a bridge for communication between different applications. It can realize data sharing, function calling and other operations, and provides developers with a relatively simple and fast development method. As an excellent PHP development framework, the ThinkPHP framework is efficient, scalable and easy to use.

What to do if shared folders cannot be accessed in Windows 10 Home Edition What to do if shared folders cannot be accessed in Windows 10 Home Edition Jan 11, 2024 pm 07:36 PM

Sharing folders is indeed an extremely useful feature in a home or business network environment. It allows you to easily share folders with other users, thereby facilitating file transfer and sharing. Win10 Home Edition shared folder cannot be accessed Solution: Solution 1: Check network connection and user permissions When trying to use Win10 shared folders, we first need to confirm whether the network connection and user permissions are normal. If there is a problem with the network connection or the user does not have permission to access the shared folder, it may result in inaccessibility. 1. First, please ensure that the network connection is smooth so that the computer and the computer where the shared folder is located are in the same LAN and can communicate normally. 2. Secondly check the user permissions to confirm that the current user has permission to share files.

5G communications are coming, but does the 5G experience really completely surpass 4G? 5G communications are coming, but does the 5G experience really completely surpass 4G? Jan 08, 2024 pm 10:30 PM

On the 28th, the 2023 Shanghai World Mobile Communications Conference (MWC2023 Shanghai) opened, and "5.5G" became a hot topic. Huawei Vice Chairman, Rotating Chairman, and CFO Meng Wanzhou also delivered a keynote speech on "Embracing the 5G Change" at the conference. , she believes that 5.5G is the inevitable path for the evolution of 5G networks. "The network characteristics of 5.5G network include 10 Gigabit downlink, 1 Gigabit uplink, 100 billion connections, and endogenous intelligence. From 5G to 5.5G, it will better match scenarios such as the Internet of Things, perception, and high-end manufacturing, and incubate More new business opportunities." What does 5.5G mean to users? We don't know yet. When the industry is already discussing 5.5G? How is the experience of 5G, which has long been popularized? 5G experience controversy: really better than 4G

See all articles