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
package httpmock | |
import ( | |
"errors" | |
"net/http" | |
) | |
// Responders are callbacks that receive and http request and return a mocked response. | |
type Responder func(*http.Request) (*http.Response, error) |
//CLIENT | |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"math/rand" | |
"net" | |
"runtime" |
//CLIENT | |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"net" | |
"runtime" | |
"sync" |
grammar expr; | |
parse | |
: expression* EOF | |
; | |
expression | |
: assignmentExpression | |
; |
>>> 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 |