How would you structure a program in Golang to ensure that a piece of data remains in volatile memory and is never cached to disk or swap?
I am trying to implement bloom filter for usernames to minimise disk reads.
With reference to Ensuring Secure Data Remains in Memory, I am looking for a solution in golang for a different purpose.
You can invoke the mlock
syscall (and its kin) in Go, using the syscall
package. See https://golang.org/pkg/syscall/#Mlock, for example.
That said, with the Go garbage collector that may not be 100% bullet-proof if you need cryptographic safety (e.g. ensure that keys never get to disk). You may want to consider libraries like memguard in that case.