summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML/Store
diff options
context:
space:
mode:
authorOlav Morken <olav.morken@uninett.no>2010-08-09 08:51:02 +0000
committerOlav Morken <olav.morken@uninett.no>2010-08-09 08:51:02 +0000
commita7e38a70fa4ce0f9ebdea85d8cde422046b401d1 (patch)
tree05c80b5f7e4c0e5c8ef2dc196007a61f8c959787 /lib/SimpleSAML/Store
parent1bd0844b86b373813264c0d179e8e91d70036724 (diff)
downloadsimplesamlphp-a7e38a70fa4ce0f9ebdea85d8cde422046b401d1.zip
simplesamlphp-a7e38a70fa4ce0f9ebdea85d8cde422046b401d1.tar.gz
simplesamlphp-a7e38a70fa4ce0f9ebdea85d8cde422046b401d1.tar.bz2
Implement datastore API, for session storage and other data.
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2490 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/SimpleSAML/Store')
-rw-r--r--lib/SimpleSAML/Store/Memcache.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/SimpleSAML/Store/Memcache.php b/lib/SimpleSAML/Store/Memcache.php
new file mode 100644
index 0000000..b7a0181
--- /dev/null
+++ b/lib/SimpleSAML/Store/Memcache.php
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * A memcache based datastore.
+ *
+ * @package simpleSAMLphp
+ * @version $Id$
+ */
+class SimpleSAML_Store_Memcache extends SimpleSAML_Store {
+
+ /**
+ * Initialize the memcache datastore.
+ */
+ protected function __construct() {
+ }
+
+
+ /**
+ * Retrieve a value from the datastore.
+ *
+ * @param string $type The datatype.
+ * @param string $key The key.
+ * @return mixed|NULL The value.
+ */
+ public function get($type, $key) {
+ assert('is_string($type)');
+ assert('is_string($key)');
+
+ return SimpleSAML_Memcache::get('simpleSAMLphp.' . $type . '.' . $key);
+ }
+
+
+ /**
+ * Save a value to the datastore.
+ *
+ * @param string $type The datatype.
+ * @param string $key The key.
+ * @param mixed $value The value.
+ * @param int|NULL $expire The expiration time (unix timestamp), or NULL if it never expires.
+ */
+ public function set($type, $key, $value, $expire = NULL) {
+ assert('is_string($type)');
+ assert('is_string($key)');
+ assert('is_null($expire) || (is_int($expire) && $expire > 2592000)');
+
+ SimpleSAML_Memcache::set('simpleSAMLphp.' . $type . '.' . $key, $value, $expire);
+ }
+
+
+ /**
+ * Delete a value from the datastore.
+ *
+ * @param string $type The datatype.
+ * @param string $key The key.
+ */
+ public function delete($type, $key) {
+ assert('is_string($type)');
+ assert('is_string($key)');
+
+ SimpleSAML_Memcache::delete('simpleSAMLphp.' . $type . '.' . $key, $value, $expire);
+ }
+
+}