This is an example of a sharded map using spin locks. It is extremely fast.
BenchmarkCacheSet-8 30000000 52.6 ns/op 0 B/op 0 allocs/op
BenchmarkCacheGet-8 30000000 37.7 ns/op 0 B/op 0 allocs/op
| //CLIENT | |
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "io" | |
| "math/rand" | |
| "net" | |
| "runtime" |
| //CLIENT | |
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "io" | |
| "net" | |
| "runtime" | |
| "sync" |
| >>> INSERT { | |
| ... year: 2014, month: 4, day: 1, | |
| ... key: '20140401', | |
| ... value: 1 | |
| ... } INTO COUNTER visits; | |
| { status_code: 2000, status: 'OK' } | |
| >>> INSERT {key: '0x045678', value: 5} INTO CACHE latest_voltage; | |
| { status_code: 2000, status: 'OK' } |
| Create directory in ST3 Packages: eg. gosub | |
| Copy GIST file into new directory: | |
| /Users/mfranks/Library/Application Support/Sublime Text 3/Packages/gosub/gosubl.py |
| from tributary.core import Engine, Message, ExecutionContext, Service | |
| from tributary.streams import StreamElement, StreamProducer | |
| from tributary.events import StopMessage, STOP | |
| import tributary.ext.fs as fs | |
| import tributary.ext.ipc as ipc | |
| from collections import defaultdict | |
| import operator | |
| import logging |
| import tributary | |
| from tributary.core import Engine, Message | |
| from tributary.streams import StreamElement, StreamProducer | |
| from tributary.events import StopMessage, STOP | |
| import tributary.ext.fs as fs | |
| import decimal | |
| import time | |
| import logging | |
| import pyhash |
| <html lang="en"> | |
| <head> | |
| <!-- Meta --> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" type="text/css" href="main.css"> | |
| <link rel="stylesheet" type="text/css" href="rework-grid.css"> | |
| </head> |