This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"fmt" | |
"time" | |
"github.com/go-redis/redis" | |
) | |
type janitor struct { | |
*redis.Client | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const add = (a, b) => (a + b); | |
const cachingFunc = (cacheObj = {}) => { | |
const cache = cacheObj; | |
return (a, b) => { | |
let hash = `${a}:${b}`; | |
if (!cache[hash]) { | |
console.log('Computing result'); | |
cache[hash] = add(a, b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loki = require('lokijs'); | |
var db = new loki('demo.json'), | |
users = db.addCollection('users'); | |
users.insert({ name: 'joe', age: 40 }); | |
users.insert({ name: 'jack', age: 32}); | |
var result = users.find({ $age: { $gt: 35 }}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myapp') | |
.service('LocalDatabase', ['$rootScope', '$window', 'LOCAL_DB', function ($rootScope, $window, LOCAL_DB) { | |
var filesystem, db = new loki('mydb'), user, users, coupons; | |
$window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, obtainedFS, fail); | |
function obtainedFS(fs) { | |
filesystem = fs; | |
loadDatabase(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('app'); // Module to control application life. | |
var BrowserWindow = require('browser-window'); // Module to create native browser window. | |
var loki = require('lokijs'), | |
db = new loki(), | |
users = db.addCollection('users', { | |
indices: ['username'] | |
}); | |
users.insert({ username: 'joe', age: 40}); | |
users.insert({ username: 'jack', age: 30}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rdb = require('rethinkdb'), | |
loki = require('lokijs'), | |
db, | |
connection; | |
function forwardInsert(db, connection, table, record, callback) { | |
var cb = callback || function (err, obj) { | |
if (err) { | |
throw err; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Collection = require('lokijs').Collection; | |
var obj = JSON.parse('serializedCollection.js'), | |
coll = new Collection('myColl'); | |
Object.keys(obj).forEach(function (prop) { | |
coll[prop] = obj[prop]; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loki = require('lokijs'), | |
db = new loki('test.json'), | |
doctors = db.addCollection('doctors'); | |
var Log = console.log; | |
doctors.insert({ | |
name: 'David Tennant', | |
doctorNumber: 10 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loki = require('lokijs'), | |
db = new loki('test.json'), | |
db2 = new loki('test.json'); | |
var users = db.addCollection('users'); | |
users.insert({ | |
name: 'joe' | |
}); | |
users.insert({ | |
name: 'john' |