tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
9.15k stars 570 forks source link

questions about in_memory geodata #14

Closed jacky8787 closed 8 years ago

jacky8787 commented 8 years ago

hi,i have two questions. one is dose tile38 use redis to store geodata, and if does, how can i find related code in the project. The other is how can i use redis client to insert data by batch as tile38 uses Redis Protocol. thanks for your help!

tidwall commented 8 years ago

Hi @jacky8787

Tile38 does not use Redis for data storage. The only thing that Redis and Tile38 share is a similar API and the Redis protocol. While Tile38 borrows a lot from Redis for networking design and command structure, they are independent databases.

Which client are you using?

Any of the clients should handle batching by pipelining multiple SET commands in a single request. For more information on pipelining check out this page.

For example, you can send multiple objects at one time:

SET fleet truck1 POINT 33.51 -115.51
SET fleet truck2 POINT 33.52 -115.52
SET fleet truck3 POINT 33.53 -115.53
SET fleet truck4 POINT 33.54 -115.54
SET fleet truck5 POINT 33.55 -115.55

And Tile38 will send back:

+OK
+OK
+OK
+OK
+OK

I hope this information helps

jacky8787 commented 8 years ago

hi,thanks for your help! if i use jedis, how can i connect to tile38 server and handle batching by pipelining multiple set commands. thanks for your help.

tidwall commented 8 years ago

I haven't used jedis before, but it looks like a cool Java redis client.

Looking at the jedis README page, there's an example of connecting to a server. For Tile38 you will need to use the port 9851. So your connection code will probably look something like this.

Jedis jedis = new Jedis("localhost", 9851);

It looks like jedis supports pipelining by using the Pipeline class. There's a section on pipelining on the Advanced Usage Page.

Also, it looks like you will need to use the .sendCommand() method instead of the .set() method because Tile38 has very different arguments to the SET command.

tidwall commented 8 years ago

Hi @jacky8787, I hope you were able to find a way to work with the Jedis client. I'm closing this issue for now, but please feel free to open it up again if you run into any problems. Thanks!