How to read the results from a key value in Redis

Source: Internet
Author: User
Now there's a key,key in Redis named Wz_user.
I read Wz_user

$redis->hgetall ("Wz_user");

The value appears:
??? Array ([1170202] = a:52:{s:2: "id"; s:7: "1170202"; s:3: "pid"; s:1: "0"; s:8: "User"; s:11: "13520966111"; s:8: "Password "; s:32:" 04cb57ee0653c0f49b5ec72afcf9a15d "; s:5:" Image "; s:0:"; s:5: "Email"; s:0: ""; S:8: "Sharenum"; s:1: "0"; S:9: " Invitenum "; s:1:" 0 "; s:8:" Clicknum "; s:1:" 0 "; s:5:" Money "; s:5:" 1.000 "; S:6:" Remain "; S:5:" 1.000 "; s:12:" Invite_money " ; s:5: "0.000"; s:8: "Topmoney"; s:5: "1.000"; s:6: "Amount"; s:1: "0"; s:6: "Profit"; s:1: "0"; s:7: "Levelid"; s:1: "1"; s:7: " Account "; s:0:" "; S:6:" Txname "; s:0:" "; S:3:" Tip "; s:0:"; s:5: "Locks"; s:1: "1"; S:6: "Adjust"; s:0: "; s:2:" IP "; s:14:" 61.148.221.114 "; s:4:" Area "; s:0:"; s:8: "Reg_type"; s:1: "0"; s:7: "Created"; s:10: "1437445187"; s:7: "Encrypt"; S:6: " Dtc1ju "; s:6:" Invite "; s:0:"; s:7: "AddType"; s:1: "0"; S:2: "NC"; s:1: "0"; s:5: "Isone"; s:1: "1"; S:6: "Freeze"; s:1: "0"; s : 8: "FreeTime"; s:1: "0"; s:6: "Keyong"; s:1: "0"; s:5: "Close"; s:1: "0"; S:9: "Closetime"; s:1: "0"; s:10: "Tel_status"; s:1: " 1 "; s:7:" Payment "; s:1:" 0 "; s:10:" Paymentime "; s:1:" 0 "; s:8:" Is_white "; s:1:" 0 "; S:9:" Whitetime "; s:1:" 0 "; s:5:" token "; s:0: ""; s: 8: "Platform"; s:1: "0"; s:8: "Is_water"; s:1: "0"; S:9: "Watertime"; s:1: "0"; s:10: "Active_val"; s:1: "0"; s:5: "Score"; s:5 : "0.000"; s:10: "Sentizinum"; s:1: "0"; s:10: "Teamleader"; s:1: "0"; s:15: "Distributor_img"; s:0: ""; s:17: "Distributor_ Money "; s:5:" 0.000 "; s:16:" Distributor_team "; s:1:" 0 "; s:18:" Distributor_indent "; s:1:" 0 ";} )

Similar to the value inside the S:2: "id"; s:7: "1170202"; In the database is id=1170202
S:3: "pid"; s:1: "0"; s:8: "User"; s:11: "13520966111"; user = 13520966111 in database

How should these values be taken out of Redis's value separately?





Reply to discussion (solution)

Hget is to take a data ah.
What is your data structure like?

This is the serialized value, which can be deserialized using unserialize

Thanks to Xuzuning, iterate, get the value, deserialize a bit.

Array ([id] = + 1170202 [pid] + 0 [user] = 13520966111 [Password] = 04cb57ee0653c0f49b5ec72afcf9 a15d [Image] = [email] = [Sharenum] + 0 [Invitenum] + 0 [Clicknum] + 0 [money] =&G T 1.000 [remain] = 1.000 [Invite_money] = 0.000 [Topmoney] = 1.000 [Amount] = 0 [profit] =&gt ; 0 [Levelid] + 1 [Account] = [txname] = [Tip] = [locks] + 1 [adjust] + [IP ] = 61.148.221.114 [Area] = [Reg_type] = 0 [created] = 1437445187 [Encrypt] = Dtc1ju [ Invite] = [AddType] + 0 [NC] = 0 [Isone] = 1 [freeze] + 0 [FreeTime] = 0 [Keyon    G] = 0 [Close] = 0 [Closetime] = 0 [Tel_status] = 1 [Payment] = 0 [Paymentime] + 0 [Is_white] = 0 [Whitetime] = 0 [Token] = [platform] + 0 [Is_water] + 0 [watertime] = 0 [Active_Val] = 0 [Score] = 0.000 [Sentizinum] = 0 [Teamleader] = 0 [distributor_img] = [Distri Butor_money] = 0.000 [Distributor_team] = 0 [distributor_indent] + 0)

xuzuning Thanks, this problem has been fixed,
I have a question for you now.

Because this library is a federated query of the library, there are many federated query conditions, so the use of Redis, now want to query the information does not go through MySQL, directly from the Redis inside, how to use the obtained worth judging conditions?

For example, in Redis, there is a total of 100W data in this Wz_user key, and now I want to take the data stored in the key as data, and then judge user = 13520966111, take this data out of redis, or when locks = 1 o'clock, Take out all the Locks=1 data in this 100W bar.

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.