/** * Find the translation for the token * * @param string $token token * @param string $lang lang ISO 639-1 with first 3 letter for dialect * @return string */ public function find($token, $lang = Dynamo_Token::LANG_EN) { $filter = array(); $filter['id'] = $this->condition('id', self::C_EQ, $token); $filter['lang'] = $this->condition('lang', self::C_EQ, $lang); $query = array('TableName' => $this->_table_name, 'KeyConditions' => $filter, 'Limit' => $limit, 'ScanIndexForward' => false); return AWS_Dynamo::iterate($this->getIterator('Query', $query)); }
public function init_session($params) { $config = Arr::get($params, 'config', null); $r_iop = Arr::get($params, 'r_iop', 1); $w_iop = Arr::get($params, 'w_iop', 1); if (empty($config)) { return self::_message('`--config` is not specified.'); } if (!file_exists($config)) { return self::_message('`' . $config . '` is not a file.'); } self::_message('Reading .ini file...'); $aws = parse_ini_file($config, true); self::_message('Getting handler object...'); $handler = AWS_Dynamo::register_session_handler($aws); self::_message('Creating session table...'); $handler->createSessionsTable($r_iop, $w_iop); self::_message('Done!'); }
<?php defined('SYSPATH') or die('No direct script access.'); define('AWS_MOD_PATH', dirname(__FILE__)); /** * Use dynamo db when dynamo is specified. */ if (!empty($_SERVER['AWS_DYNAMO_SESSION'])) { $aws = parse_ini_file($_SERVER['AWS_DYNAMO_SESSION'], true); $handler = AWS_Dynamo::register_session_handler($aws); }
/** * Creates dynamo as session handler. * * locking_strategy: Locking strategy fused for doing session locking. Default: null * dynamodb_client: DynamoDbClient object used for performing DynamoDB operations * table_name: Name of the DynamoDB table in which to store the sessions. Default: "sessions" * hash_key: Name of the hash key in the DynamoDB sessions table. Default: "id" * session_lifetime: Lifetime of an inactive session before it should be garbage collected. * consistent_read: Whether or not to use DynamoDB consistent reads for GetItem. Default: true * automatic_gc: Whether or not to use PHP's session auto garbage collection triggers. * gc_batch_size: Batch size used for removing expired sessions during garbage collection. Default: 25 * gc_operation_delay: Delay between service operations during garbage collection * max_lock_wait_time: Maximum time (in seconds) to wait to acquire a lock before giving up * min_lock_retry_microtime: Minimum time (in microseconds) to wait between attempts to acquire a lock * max_lock_retry_microtime: Maximum time (in microseconds) to wait between attempts to acquire a lock * * @param array $config Session configuration * @return session handler */ public static function register_session_handler($config = array()) { // send to DynamoDb $instance = AWS_Dynamo::instance(); return $instance->registerSessionHandler($config); }