Redis Lua: Appending to a List and Trimming to Max Size
I've decided to start publishing a pattern or short snippet of code every day. Ideally this will help get my creative juices flowing, add some value to my name, and give me material to publish in...
View ArticleNode.js: MapReduce for LevelUp.
This is a Map-Reduce implementation for LevelUp. I really like the map-reduce pattern for querying keystores. I'm a big fan of Riak even though the Map part of Map-Reduce is database key specific. I...
View ArticleRedis Lua: Store JSON as MessagePack and Retrieve MessagePack as JSON
JSON is nearly universal in the web world, and Redis Lua scripting supports encoding and decoding it, which can be very useful for having advanced logic based on JSON values without having to fully...
View ArticleRedis Lua: Storing and Checking Hashed Passwords
See the update at the bottom: this approach isn't secure (but I still think it's interesting). Storing passwords in plain text is bad. Time and time again, databases get hacked and passwords get...
View ArticleRedis Lua: Collate Redis Key/Value Results
Any Redis command that returns key/value pairs returns the results as a single list of alternating keys and values. If you need to work the results in a Lua script, you'll likely want to collate them...
View ArticleRedis Lua: Updating a Key and Publishing a Logged Notification
One of the cool things about Redis Lua scripting is the ability to publish notifications of your changes atomically with those changes made. There's actually a new Redis feature that can do this for...
View ArticleRedis: Generating a Hash Lookup with SCAN
Using a keystore efficiently is all about anticipating how the data will be looked up. If you can't do that, you may be better using a relational database. Generating lookup tables and indexes can be...
View ArticleRedis Lua: Updating a Key and Lookup Hash
Yesterday I mentioned that you should maintain a lookup hash as you update keys. So today, I decided to put that together. The only real gotcha is deleting the lookup to the old attribute value before...
View ArticleReplacing Loading Images with Spinners Using Mutation Observers
Sometimes you'd rather images loading into your page don't show up until they're finished. Sometimes you don't have direct control over when images get added to your page. The MutationObserver is a...
View ArticleArchive Redis to Riak
Redis is nice for dealing with data as it is relevant and changing, but once it goes a little stale, you probably want to archive it to free up resources. Wouldn't it be nice to be able to archive it...
View ArticleCreate A Levelup Proxy to Riak
Riak is a clustered key-value database that applies "AP" from the CAP Theorem. It has HTTP and Protocol Buffers APIs, but can be a little bit cumbersome to browse keys for debugging. I've been getting...
View ArticleGenerating Reverse Sort Indexes for Riak in Node
While developing the prototype for what became @quitlahok's riakdown, I quickly realized that while Riak can give keys back in lexical order of indexes, it cannot do the same in reverse. We needed...
View ArticleUsing Postgres as a Document Store
Lately, I've been working on pgDOWN, which is a Postgres backend for levelup, so that I can support Postgres in Dulcimer. My motivation is to have a CP backend for Duclimer. Currently leveldb...
View Article