Databases Reference
In-Depth Information
For each parking facility the attributes are stored in a hash, which is identifi ed by the key of the
form parking_facility:<license_number> . Thus, to see all keys in the hash associated with
license number 1105006 you can use the following command:
HKEYS parking_facility:1105006
The response is as follows:
1. “facility_type”
2. “entity_name”
3. “camis_trade_name”
4. “address_bldg”
5. “address_street_name”
6. “address_location”
7. “address_city”
8. “address_state”
9. “address_zip_code”
10. “telephone_number”
11. “number_of_spaces”
The license number 1105006 was fi rst on the list returned by the SMEMBERS parking_facilities_
set command. However, sets are not ordered, so rerunning this command may not result in
the same license number on top. If you need the list of members to appear in a certain order, use the
sorted sets instead of the set. All you may need to do to use a sorted set is to replace the line if
r.sadd(“parking_facilities_set”, license_number): with the following:
if r.zadd(“parking_facilities_set”, license_number):
Now, you can query for specifi c values in the hash, say facility type, as follows:
HGET parking_facility:1105006 facility_type
The response is “Parking Lot” . You can also print out all values using the HVALS command as
follows:
HVALS parking_facility:1105006
The response is:
1. “Parking Lot”
2. “CENTRAL PARKING SYSTEM OF NEW YORK, INC”
3. “”
4. “41-61”
5. “KISSENA BOULEVARD”
6. “”
7. “QUEENS”
8. “NY”
9. “11355”
10. “2126296602”
11. “808”
Search WWH ::




Custom Search