Skip to content

Instantly share code, notes, and snippets.

View kristoff-it's full-sized avatar
in your codebase, fixing your bugz

Loris Cro kristoff-it

in your codebase, fixing your bugz
View GitHub Profile
const std = @import("std");
pub const io_mode = .evented;
// Loris: This is an unfortunate combination of traps that you stumbled upon.
// Reader / Writer interfaces are generic (ie the type changes based on the underlying stream).
// In Zig we use the term "interface" very broadly to refer to anything that fulfills a predetermined API.
// This is very different than say, Go, where "interface" is a concrete feature of the language that
// only offers one specific way of doing runtime polymorphism. Going back to Zig, the problem here is
// that stdin and stdout are `std.fs.File` structs, while the socket is a `std.net.Stream`, which means
package main
import (
"fmt"
"time"
"github.com/go-redis/redis"
"github.com/kristoff-it/redis-memolock/go/memolock"
)
func main () {
const std = @import("std");
const time = std.time;
const Timer = time.Timer;
const net = std.net;
const fs = std.fs;
pub const io_mode = .evented;
const NUM_CLIENTS = 5;
const MSG_SIZE = 4096 * 512;
const std = @import("std");
const time = std.time;
const builtin = @import("builtin");
const heyredis = @import("./src/okredis.zig");
pub const io_mode = .evented;
const addr = if (builtin.os.tag == .linux) "192.168.65.2" else "127.0.0.1";
pub fn main() !void {
$ redis-cli hset vec:1 x 10 y 5 z 23
$ redis-cli hset vec:2 x 2 y 5 z 5
$ python3
>>> import redis
>>> r = redis.Redis(decode_responses=True) # decode_responses is useful in py3
>>> script = open("path/to/script.py", 'r').read()
>>> r.execute_command("RG.PYEXECUTE", script)
[['14.0', '5.0', '6.0'], []]
const std = @import("std");
const time = std.time;
const builtin = @import("builtin");
const heyredis = @import("./src/okredis.zig");
pub const io_mode = .evented;
const addr = "127.0.0.1";
pub fn main() !void {
import asyncio, aioredis
async def main():
pool = await aioredis.create_redis_pool('localhost',
db=0, password=None, ssl=False, minsize=4, maxsize=10, encoding='utf8')
# Assuming we're not the only ones using the pool
start_other_coroutines_that_use_redis(pool)
# This time we do a transaction
const std = @import("std");
const time = std.time;
const builtin = @import("builtin");
const heyredis = @import("./src/heyredis.zig");
const addr = if (builtin.os == .linux) "192.168.65.2" else "127.0.0.1";
pub const io_mode = .evented;
pub fn main() !void {
if (std.io.is_async) {
@kristoff-it
kristoff-it / faas.js
Last active September 18, 2019 14:44
// Connection info, a URI with this shape:
// [redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
const REDIS_URI = process.env.REDIS_URI;
// Redis client library
const redis = require('redis');
// Client instance
const r = redis.createClient(REDIS_URI);
import redis
# The operation to perform for each event
def add_new_win(conn, winner):
conn.zincrby('wins_counter', 1, winner)
conn.incr('total_games_played')
def main():
# Connect to Redis