Skip to content

Instantly share code, notes, and snippets.

View benbristow's full-sized avatar

Ben Bristow benbristow

View GitHub Profile
@benbristow
benbristow / stash.php
Created November 20, 2017 16:27
Implementation of 'Rails.cache.fetch' using Stash PHP Library
<?php
use Stash\Driver\Redis;
use Stash\Pool;
class Cache {
public static function fetch(String $namespace, String $key, $expiresAfter, $callback) {
$pool = new Pool(new Redis());
$item = $pool->getItem($namespace . '/' . hash('sha256', $key));
$data = $item->get();
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost Database: samdb
-- ------------------------------------------------------
-- Server version 5.0.45-community-nt
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
Verifying my Blockstack ID is secured with the address 1J97m2GJHkLwr6WSHhmKaPd24uNZP4N4dT https://explorer.blockstack.org/address/1J97m2GJHkLwr6WSHhmKaPd24uNZP4N4dT
-----> uname: Linux dokku 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
-----> memory:
total used free shared buff/cache available
Mem: 1993 407 737 1 848 1397
Swap: 0 0 0
-----> docker version:
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3