---
title: Drift quickstart
description: Install Drift, create a bounded TTL cache, and verify a value from a Node.js process.
url: https://pr-15-c0fdf0ef9f59.thally.app/drift/quickstart
---

# Drift quickstart

Install Drift, create a bounded TTL cache, and verify a value from a Node.js process.

In this quickstart, you will create an in-process cache with a default TTL and
an LRU capacity. You need Git and Node.js 18 or later. Drift is not published
to npm yet, so this baseline builds the package from its public repository.

#### Clone and build Drift

    ```bash
    git clone https://github.com/kenny-io/driftkv.git
    cd driftkv
    npm install
    npm run build
    ```

#### Create a cache

    Save this as `quickstart.mjs`:

    ```javascript
    import { createStore } from "driftkv";

    const cache = createStore({
      maxEntries: 100,
      defaultTtlMs: 60_000,
    });

    cache.set("session:9f2c", { user: "ada" });

    console.log(cache.get("session:9f2c"));
    console.log(cache.size());
    console.log(cache.ttl("session:9f2c") > 0);
    ```

#### Run and verify it

    ```bash
    node quickstart.mjs
    ```

    The process prints `{ user: 'ada' }`, `1`, and `true`. The read also marks
    the entry as most recently used.

## Add types in a TypeScript application

The generic value type flows through every store method:

```typescript
import { createStore } from "driftkv";

interface Session {
  user: string;
  scopes: string[];
}

const sessions = createStore<Session>({ maxEntries: 1_000 });
sessions.set("9f2c", { user: "ada", scopes: ["checkout:read"] });

const session = sessions.get("9f2c"); // Session | undefined
```

Next, read [Drift concepts](/drift/concepts) before choosing TTL, eviction, or
persistence behavior for a long-lived process.