1.1 A case study:design and implementation of a simple Twitter clone using only the Redis Key-value store as data Base and PHP
This chapter will describe a design and implementation that mimics Twitter applications, using PHP and Redis as a unique database. The programmer community often key-value storage as a special database and cannot be used in lieu of relational databases in Web application developmen
data is not allowed (get LSF means to obtain the value of the key corresponding to the name LSF, set key value is the opposite, such as set LSF "Lingshufeng" Represents a key value pair that is stored in a key of Lsf,value as Lingshufeng
No password login Direct error is not allowed, this means that the need for password login, specifically for the operation of the map, in the back plus-a foobared, that is-a password, you can log in.
In addition, you can get the LSF corresponding data, here why
EVAL script Numkeys key [key ...] arg [arg ...]
Starting with the Redis 2.6.0 release, the LUA script can be evaluated using the EVAL command with the built-in LUA interpreter.The script parameter is a LUA 5.1 script that runs in the Redis server context, which does not have to (and should not) be defined as a LUA function.The Numkeys parameter is used to specify the number of key name parameters.Key Name
0. Installation and testing
Installing Redis on WindowsRedis 's official website is Redis.io, the installation of Redis to Windows, you can unzip the attachment redis.zip to any local path (such as: e-disk).
Start Redis Server SideUse the Cmd.exe tool to enter the unzipped Redis folder and enter th
Application ScenariosRecently in the company to do projects, need to store chat content, taking into account the database query the number of IO connections high, connected frequently factors, decided to use the cache.Knowing from the web that Redis can store all the content in binary, and that Java is able to serialize all the objects, the serialized method provides the implementation in the following code
: key fieldReturned value: if the hash table contains a given field, 1 is returned. If the hash table does not contain a specified field or the key does not exist, 0 is returned.
10, hincrby
Description: adds an incremental increment to the field value of the hash table key. An increment can also be a negative number, which is equivalent to performing a subtraction operation on a given domain.Parameter: key field incrementReturned Value: The field value in the key of the hash table after the HIN
from a mapJedis.hdel ("User", "age"); System.out.println (Jedis.hmget ("User", "age");//because it was deleted, NULL is returned .System.out.println (Jedis.hlen ("user"));//returns the number of values stored in the key for user 2System.out.println (jedis.exists ("user"));//If there is a record of key user, returns TrueSystem.out.println (Jedis.hkeys ("user"));//returns all keys in the map objectSystem.out.println (jedis.hvals ("user"));//returns all the value in the Map objectIterator). iterat
filed1 ..... fieldn//Get all specified hash filed04hmset key filed1 value1 ... filedn valuen//Set hash multiple Field05hincrby key field integer/ /Add the specified hash filed to the given Value 06hexists key field//test Specifies whether field exists 07hdel key field//delete specified hasH Field08hlen key//Returns field number of the specified hash 09hkeys key//return hash of all field10hvals key Return hash of all value11hgetall//return hash of all filed and value3.
so on.You can also use a negative subscript, which means 1 for the last member, 2 for the penultimate member, and so on.An out-of-range subscript does not cause an error.For example, when the value of start is larger than the maximum subscript for an ordered set, or Start > Stop, the Zrange command simply returns an empty list.On the other hand, if the value of the stop parameter is larger than the maximum subscript for an ordered set,
InstallationTo use Redis in a Java program, you need to make sure that there are redis Java drivers and Java settings on the machine. You can check out the Java tutorial-Learn how to install J
《Integration of Spring 4 (including MVC, Context, ORM) + MyBatis 3 ExampleArticle briefly introduces the latest version of the Spring MVC, IOC, MyBatis ORM integration and declarative transaction processing. Now we need to integrate the cache, and we're using Redis, and this article will cover the integration of Redis cache + Spring on the basis of this example.
now a ready-to-accept connections on PORT 6379Indicates that the Redis service started successfully. Double-click, Redis-cli.exe Client, test, input, set age 21 back to car, next line, get age enter, if output 21, it means that you installed Redis successfully.Second, Redis store
This article mainly introduces 30 common php method code examples for redis operations. In this article, there are actually more than 30 methods that can be used to operate data of the string, list, and set types, for more information, see
This article mainly introduces 30 common php method code examples for redis operations. In this article, there are actually more than 30 methods that can be used to opera
cache of the Provincecities method has been cleaned out and the cache of the Insertcity method works.Then verify the cache configuration of the Renamecity method, JMeter calls the/bdp/city/rename.json interface:Then look at Redis storage:The cache of the Searchcity method has also been cleaned up, and the caching of the Renamecity method has worked.7. Precautions
The Java object to be cached must
storage:
The cache of the searchCity method has been cleared, and the cache of the renameCity method also works.
7. note: The Java object to be cached must implement the Serializable interface, because Spring will serialize the object before saving it to Redis, such as com. defonds. bdp. city. bean. city class. If Serializable is not implemented, the following error occurs: nested exception is
Redis was installed in the Windows environment yesterday.Below you are ready to test the use of Redis in a Java project.The Redis website recommends using Jedis to access Redis. So first the Jedis jar package is prepared, and the jar packages that need to be relied upon.comm
Application ScenariosRecently in the company to do projects, need to store chat content, taking into account the database query the number of IO connections high, connected frequently factors, decided to use the cache.Knowing from the web that Redis can store all the content in binary, and that Java is able to serialize all the objects, the serialized method provides the implementation in the following code
Example of redis queue operation (php ). The code for copying data to the queue is as follows :? Php $ redisnewRedis (); $ redis-connect (127.0.0.1, 6379); while (True) {try {$ valuevalue _. date (Y-m-dH: I: s); $ redis-LPUSH (key1, $ v join operations
The code is as follows:
$
$redis = new Redis ();$redis->connect (' 127.0.0.1 ', 6379);echo "Connection to server sucessfully";Store data in Redis list$redis->lpush ("Tutorial-list", "Redis");$redis->lpush ("Tuto
One. Add dependencyTwo. Example:1. Create Jedis Object Operations RedisConstructing Jedis objectsJedis Jedis = new Jedis ("127.0.0.1", 6379);Adding data to RedisJedis.set ("MyTest", "123bin");Reading data from RedisString value = Jedis.get ("mytest"); System.out.println (value);Close connectionJedis.close (); 2. Build connection pool configuration information by connecting pooling//Jedispoolconfig jedispoolconfig = new Jedispoolconfig ();Set maximum n
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.