Riak has a configurable backend system.
Riak's default backend is Bitcask. Bitcask persists all data to disk on write, while keeping all keys in memory. The system's file caching is relied on when reading data as to whether a particular value is in memory or not. While this article is a bit old, it covers how bitcask works pretty well at the high level.
If you want to simply store everything in memory and not persist to disk, you can configure Riak to use a memory-only backend. This is done via the app.config
file in the riak_kv
section:
{riak_kv, [
%% Storage_backend specifies the Erlang module defining the storage
%% mechanism that will be used on this node.
% {storage_backend, riak_kv_bitcask_backend},
{storage_backend, riak_kv_memory_backend},