I just had this quick idea that Windows Registry can be used as a NoSQL database. It's already a key-value registry. It even has data types such as strings, binary data, numbers and others. It's also ACID and probably the most well tested database in the world with billions of installations across the world.
Let that sink in. BILLIONS. MongoDB who?
You think Redis is fast? Try reg.exe
– it ships with the OS. You want a 0ms query latency? Boom. It's already in memory. Ever tried querying HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer
? That's your user context database, buddy.
Let's be honest: The Registry is a NoSQL document store. It's hierarchical, schema-less (don't let MSDN tell you otherwise), supports versioning via system restore points, and best of all – it survives BSODs, ransomware, and the wrath of 15-year-olds installing Counter-Strike 1.6 mods.
Sample Query
Want to insert a value? Here's your new ORM:
reg add "HKCU\Software\MyApp\Database\Users\user123" /v email /t REG_SZ /d "user123@example.com"
Boom. Record inserted.
Want to read it back?
reg query "HKCU\Software\MyApp\Database\Users\user123" /v email
BOOM. Query executed. No SQL injections here. You'd have to inject a COM component just to break this thing. Hackers hate it.
The Registry Has Transactions (Yes, Really)
Nobody believes me when I say this, but Windows Registry is secretly a transactional database. All the write operations go through RegSaveKey
and its friends. It's not MVCC like PostgreSQL, but it doesn't need to be. It's designed for things like boot-critical config changes and weird OEM hacks that turn your laptop keyboard into a MIDI controller.
Also, the hive files (NTUSER.DAT
, SYSTEM
, SOFTWARE
) are basically SQLite .db
files without the dignity of being treated seriously.
Features You Didn't Know You Had
Replication
Roaming profiles, baby.
Backup
System Restore Points. Also reg export
. You like backups? Here, have a text file of your entire DB.
Security
Built-in ACLs per key. It’s like fine-grained role-based access control with the personality of NTFS.
Logging
Not built-in, but just set a file system watcher on C:\Windows\System32\config
and pretend you're ELK Stack.
Downsides?
Yeah, sure, there are a few:
- No cloud support (yet).
- No Docker integration.
- People will think you've gone mad.
- You have gone mad.
Bonus: Registry as a PubSub Bus
Here's a demented idea: build a message bus on top of the Registry using value-changed events.
Set up a watcher in PowerShell:
Register-WmiEvent -Query "SELECT * FROM RegistryValueChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND KeyPath='SOFTWARE\\MyApp\\Queue'" -Action {
Write-Host "A new message has arrived!"
}
Boom. Message queue. Kafka is shaking.
Registry as a CMS (Content Management System)
Think WordPress is bloated? Try serving a webpage where all content is stored in the Registry.
reg add "HKLM\Software\MyWeb\Pages\Home" /v Content /t REG_SZ /d "<h1>Hello, Registry World!</h1>"
Now write a Python Flask app that pulls page content from the registry:
from flask import Flask
import winreg
app = Flask(__name__)
@app.route("/")
def home():
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\MyWeb\Pages\Home")
content, _ = winreg.QueryValueEx(key, "Content")
return content
app.run()
Congratulations. You've created the most cursed CMS of all time.
And it still runs faster than Drupal.
Final Thoughts
I'm not saying you should build your next fintech startup on top of the Windows Registry. I'm just saying you could. And maybe that's what matters.
The real NoSQL database was inside us all along. It was hiding behind regedit.exe
, smirking like a maniac.
Now go out there, install a root certificate, and start writing JSON to HKLM\Software
. Let the madness begin.
And as always – stay irrational.
P.S. Coming next: "Excel Sheets as a Distributed File System". (Spoiler: It works. Sort of.)