Quickstart
Use Loft as a KV cache.
Install the client from this repo, then point it at https://api.loftmemory.com. A missing key is a cache miss. Keep the real copy somewhere else.
pip install -e sdk/python
from loft import MemoryTier
mt = MemoryTier("mtk_...", base_url="https://api.loftmemory.com")
mt.put("hello", "world", ttl_seconds=3600) # cache, standard price
mt.put("keep", "safe", durability="durable") # two or three copies
mt.put("hot", "pin", durability="durable", tier="reliable") # 2x, reliable hosts only
print(mt.get("hello"))
tier="reliable" costs twice the memory rate and is placed only on desktops and servers with at least 95% uptime over the last 7 days and a fast measured link. The default tier is standard. Hosts still receive 80%.
Batch embedding cache
import hashlib
from loft import MemoryTier
mt = MemoryTier("mtk_...", base_url="https://api.loftmemory.com")
def embed_cached(texts):
missing, order = [], []
for text in texts:
key = "emb-" + hashlib.sha256(text.encode()).hexdigest()
try:
order.append(mt.get(key))
except Exception:
missing.append((key, text))
order.append(None)
if missing:
vectors = mt.embed([text for _, text in missing])
for (key, _), vec in zip(missing, vectors):
mt.put(key, str(vec), ttl_seconds=86400)
return order