Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
Redis
cache($key, $val='', $ttl='')
1
found
auth
Name:
Category: Redis
Body:
Old code, check if still compatible. Uses library: https://github.com/nicolasff/phpredis#classes-and-methods // getRedis() / function getRedis() { static $instance; if (! $instance) { $instance = new Redis; $instance->connect('localhost'); } return $instance; } //________________________________ // cache($key, $val='', $ttl='') / function cache($key, $val='', $ttl='') { global $cache_hits; // if (NO_CACHE) return false; if (! $key) return false; if (! $r = getRedis()) { return false; } if ($val) { if ($ttl) { $r->setex($key, $ttl, $val); }else{ $r->set($key, $val); } }else{ $res = $r->get($key); if ($res) { $cache_hits++; } return $res; } }
Footer