In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "detailed explanation of Redis Geo-related commands". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "detailed explanation of Redis Geo-related commands".
GEOADD
Earliest available version: 3.2.0
Time complexity: O (log (N)), where N is the number of Sorted set elements
Usage: GEOADDkey longitude latitude member [longitude latitude member …]
Adds the specified geospatial location (latitude, longitude, name) to the specified key. This data is stored in sorted set to facilitate the use of GEORADIUS or GEORADIUSBYMEMBER commands.
This command takes the standard format parameter xpene y, so longitude must precede latitude. The coordinates entered have the following limitations:
Valid longitude from-180 degrees to 180 degrees
Valid latitudes range from-85.05112878 to 85.05112878 degrees
The command returns an error when the coordinate location is outside the specified range.
GEODIST
Earliest available version: 3.2.0
Time complexity: O (log (N))
Usage: GEODIST key member1 member2 [unit]
Returns the distance between two given positions.
If one of the two locations does not exist, the command returns a null value.
The parameter unit for the specified unit must be one of the following:
M represents the unit in meters
Km means the unit is kilometer
Mi stands for miles.
Ft represents the unit in feet
If the user does not display the specified unit parameter, meters are used as the unit by default.
The GEODIST command assumes that the earth is perfectly spherical when calculating the distance, and in extreme cases, this assumption can cause a maximum error of 0.5%.
GEOHASH
Earliest available version: 3.2.0
Time complexity: O (log (N))
Returns a Geohash representation of one or more element positions.
Usage: GEOHASH key member [member …]
Returns the Geohash representation of one or more location elements.
Typically, Redis uses a variant of Geohash technology to represent the location of an element, which is encoded using a 52-bit integer. Because the initial maximum and minimum coordinates of encoding and decoding are different, coding is not a standard coding method.
This command returns an 11-character Geohash string with no loss of precision compared to the internal 52-bit representation. The returned Geohash has the following properties:
It can remove the characters on the right to shorten the length, which only results in a loss of precision, but still points to the same area.
It can be used on the heohash.org website at http://geohash.org/
Strings with similar prefixes point to a very close position, but that doesn't mean strings with different prefixes are far away.
GEOPOS
Earliest available version: 3.2.0
Time complexity: O (log (N))
Usage: GEOPOS key member [member …]
Returns the specified location information in the specified key.
GEORADIUS
Earliest available version: 3.2.0
Time complexity: O (N+log (M)), N is the number of elements in the radius area, M is the number of elements in the specified key
Usage: GEORADIUS key longitude latitude radiusm | km | ft | mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC | DESC] [STORE key] [STOREDIST key]
Returns all location elements whose location elements are no more than the maximum distance from the center, centered on a given latitude and longitude.
Command additional options:
WITHDIST: when the location element is returned, the distance between the location element and the center is also returned, and the unit of the given distance from the user is always
WITHCOORD: returns the longitude and latitude of the location element as well
WITHHASH: returns the ordered set score of the position element encoded by the original geohash as a 52-bit signed integer. This option is mainly used for underlying applications or debugging.
The command returns results unsorted by default, and you can specify ASC or DESC to sort by distance.
COUNT indicates that the number of elements returned is specified, and if not specified, all elements that match are returned.
When the GEORADIUS and GEORADIUSBYMEMBER commands have STORE and STOREDIST parameters, they are marked as write commands. In a cluster, if READONLY is set, they will be redirected to the primary node, even if they are not writing. But to solve this problem, variants of these two commands, GEORADIUS_RO and GEORADIUSBYMEMBER_RO, are introduced in Redis4.0.
GEORADIUSBYMEMBER
Earliest available version: 3.2.0
Time complexity: O (N+log (M)), N is the number of elements in the radius area, M is the number of elements in the specified key
Usage: GEORADIUSBYMEMBER key member radiusm | km | ft | mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC | DESC] [STORE key] [STOREDIST key]
This command, like the GEORADIUS command, can find elements within the location range, but the way to specify the center point is different. This command directly specifies the element in key as the center, rather than latitude and longitude like GEORADIUS.
At this point, I believe you have a deeper understanding of the "detailed explanation of Redis Geo-related commands", you might as well come to the actual operation! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.