Skip to content

Instantly share code, notes, and snippets.

View guyroyse's full-sized avatar

Guy Royse guyroyse

View GitHub Profile
import { Entity, Schema, Client, Repository } from 'redis-om'
class Album extends Entity {}
let schema = new Schema(Album, {
artist: { type: 'string' },
title: { type: 'string' },
year: { type: 'number' },
genres: { type: 'array' },
outOfPublication: { type: 'boolean' }
})
import { Entity, Schema, Client, Repository } from 'redis-om'
@guyroyse
guyroyse / 1 - entity.js
Last active November 9, 2021 21:49
Redis OM Quick Sample
class Album extends Entity {}
let schema = new Schema(Album, {
artist: { type: 'string' },
title: { type: 'string', textSearch: true },
year: { type: 'number' }
});
import Redis from 'ioredis'
const redis = new Redis()
async function main() {
await redis.flushall()
console.time('total')
console.log()
@guyroyse
guyroyse / client.js
Created February 24, 2021 20:43
Wrapping module calls the ioredis way.
import Redis from 'ioredis'
import * as ioredisearch from './ioredisearch'
let r = new Redis()
ioredisearch.use(r)
let results = yield r.list()
import asyncio
import aioredis
from pprint import pp
async def main():
redis = await aioredis.create_redis('redis://:foobared@localhost:6379/0', encoding='utf-8')
await asyncio.gather(
import asyncio
import aioredis
from pprint import pp
async def main():
redis = await aioredis.create_redis('redis://:foobared@localhost:6379/0', encoding='utf-8')
await redis.execute('FT.DROP', 'bigfoot:sightings:search')
import asyncio
import aioredis
from pprint import pp
async def main():
redis = await aioredis.create_redis('redis://:foobared@localhost:6379/0', encoding='utf8')
last_id = '0-0'
import asyncio
import aioredis
async def main():
redis = await aioredis.create_redis('redis://:foobared@localhost:6379/0', encoding='utf-8')
await asyncio.gather(
add_to_stream(redis, 1, 'Possible vocalizations east of Makanda', 'Class B'),
add_to_stream(redis, 2, 'Sighting near the Columbia River', 'Class A'),
import asyncio
import aioredis
from pprint import pp
async def main():
redis = await aioredis.create_redis('redis://:foobared@localhost:6379/0', encoding='utf-8')
[channel] = await redis.psubscribe('bigfoot:broadcast:channel:*')