{"size": 738, "ext": "js", "max_stars_repo_path": "server/stores/redis.js", "max_stars_repo_name": "nondejus/lnurl-node", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/stores/redis.js", "max_issues_repo_name": "nondejus/lnurl-node", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/stores/redis.js", "max_forks_repo_name": "nondejus/lnurl-node", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.4210526316, "max_line_length": 50, "alphanum_fraction": 0.6260162602}
module.exports = function(lnurl) {

	const Redis = require('ioredis');

	let Store = function(options) {
		this.options = options || {};
		this.client = new Redis(this.options);
	};

	Store.prototype.save = function(hash, data) {
		const value = JSON.stringify(data);
		return this.client.set(hash, value).then(() => {
			return;
		});
	};

	Store.prototype.exists = function(hash) {
		return this.client.exists(hash).then(value => {
			return value === 1;
		});
	};

	Store.prototype.fetch = function(hash) {
		return this.client.get(hash).then(value => {
			const data = JSON.parse(value);
			return data;
		});
	};

	Store.prototype.close = function() {
		return this.client.quit().then(() => {
			return;
		});
	};

	return Store;
};
