Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/melihmucuk/geocache
Geocache is an in-memory cache that is suitable for geolocation based applications.
https://github.com/melihmucuk/geocache
cache geocaches geofence geolocation geolocation-cache golang
Last synced: 3 months ago
JSON representation
Geocache is an in-memory cache that is suitable for geolocation based applications.
- Host: GitHub
- URL: https://github.com/melihmucuk/geocache
- Owner: melihmucuk
- License: mit
- Created: 2016-06-21T10:48:34.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-21T16:53:18.000Z (almost 8 years ago)
- Last Synced: 2024-01-26T00:41:16.522Z (5 months ago)
- Topics: cache, geocaches, geofence, geolocation, geolocation-cache, golang
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 140
- Watchers: 7
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go-storage - geocache - An in-memory cache that is suitable for geolocation based applications. (Database)
- awesome-go - geocache - In-memory cache that is suitable for geolocation based applications. (Database / Advanced Console UIs)
- awesome-go - geocache - memory cache that is suitable for geolocation based applications. | - | - | - | (Geographic / Advanced Console UIs)
- awesome-go-with-framework - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go - geocache - 适用于基于地理位置的应用程序的内存缓存。 (<span id="数据库-database">数据库 Database</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go. - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go-cn - geocache - 基于内存存储的缓存,适用于分布式部署的应用 (数据库 / 高级控制台界面)
- awesome-go - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-Char - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-reader - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go-storage - geocache - An in-memory cache that is suitable for geolocation based applications. (Database)
- awesome-go - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go-cn - geocache - memory cache that is suitable for geolocation based applications.) (Geographic / Advanced Console UIs)
- awesome-go - geocache - An in-memory cache that is suitable for geolocation based applications. (Database / Advanced Console UIs)
- awesome-go-handwritten - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go - geocache - 基於內存存儲的緩存,適用於分佈式部署的應用 (數據庫 / 高級控制台界面)
- awesome-go2 - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go - geocache - An in-memory cache that is suitable for geolocation based applications. (Database / Advanced Console UIs)
- awesome-go - geocache - In-memory cache that is suitable for geolocation based applications. (Geographic / Advanced Console UIs)
- awesome-go - geocache - In-memory cache that is suitable for geolocation based applications. - :arrow_down:0 - :star:47 (Geographic / Advanced Console UIs)
- awesome-go-cn - geocache
- awesome-go-cn - geocache
- awesome-go - geocache - Geocache is an in-memory cache that is suitable for geolocation based applications. - ★ 93 (Geographic)
- go-awesome-cn-star - geocache
README
# geocache [![GoDoc](https://godoc.org/github.com/melihmucuk/geocache?status.svg)](https://godoc.org/github.com/melihmucuk/geocache) [![Go Report Card](https://goreportcard.com/badge/melihmucuk/geocache)](https://goreportcard.com/report/melihmucuk/geocache) [![Build Status](http://img.shields.io/travis/melihmucuk/geocache.svg?style=flat)](https://travis-ci.org/melihmucuk/geocache)
geocache is an in-memory cache that is suitable for geolocation based applications. It uses geolocation as a key for storing items. You can specify range on initialization and thats it! You can store any object, it uses interface.
### Installation
`go get github.com/melihmucuk/geocache`
### Usage
![geolocation cache](http://i.imgur.com/O6UzVEW.png "Geolocation Cache")
```go
import (
"fmt"
"time""github.com/melihmucuk/geocache"
)func main() {
c, err := geocache.NewCache(5*time.Minute, 30*time.Second, geocache.WithIn1KM)
geoPoint := geocache.GeoPoint{Latitude: 40.9887, Longitude: 28.7817}
if err != nil {
fmt.Println("Error: ", err.Error())
} else {
c.Set(geoPoint, "helloooo", 2*time.Minute)
v1, ok1 := c.Get(geocache.GeoPoint{Latitude: 41.2, Longitude: 29.3})
v2, ok2 := c.Get(geocache.GeoPoint{Latitude: 41.2142, Longitude: 29.4234})
v3, ok3 := c.Get(geocache.GeoPoint{Latitude: 40.9858, Longitude: 28.7852})
v4, ok4 := c.Get(geocache.GeoPoint{Latitude: 40.9827, Longitude: 28.7883})
fmt.Println(v1, ok1)
fmt.Println(v2, ok2)
fmt.Println(v3, ok3)
fmt.Println(v4, ok4)
}
}```
outputs:
```
, false
, false
helloooo, true
helloooo, true
```### Information
You can specify 8 different range. More info can be found [here](http://gis.stackexchange.com/questions/8650/how-to-measure-the-accuracy-of-latitude-and-longitude).
* `WithIn11KM`
The first decimal place is worth up to 11.1 km `eg: 41.3, 29.6`
* `WithIn1KM`
The second decimal place is worth up to 1.1 km `eg: 41.36, 29.63`
* `WithIn110M`
The third decimal place is worth up to 110 m `eg: 41.367, 29.631`
* `WithIn11M`
The fourth decimal place is worth up to 11 m `eg: 41.3674, 29.6316`
* `WithIn1M`
The fifth decimal place is worth up to 1.1 m `eg: 41.36742, 29.63168`
* `WithIn11CM`
The sixth decimal place is worth up to 0.11 m `eg: 41.367421, 29.631689`
* `WithIn11MM`
The seventh decimal place is worth up to 11 mm `eg: 41.3674211, 29.6316893`
* `WithIn1MM`
The eighth decimal place is worth up to 1.1 mm `eg: 41.36742115, 29.63168932`