izzum\statemachine\persistence\Redis::insertState PHP Method

insertState() public method

{@inheritDoc}
public insertState ( Identifier $identifier, $state, $message = null )
$identifier izzum\statemachine\Identifier
    public function insertState(Identifier $identifier, $state, $message = null)
    {
        $redis = $this->getRedis();
        try {
            $redis->multi(\Redis::MULTI);
            //add to set of known id's
            $key = sprintf(self::KEY_ENTITYIDS, $identifier->getMachine());
            $redis->sadd($key, $identifier->getEntityId());
            //set the state
            $key = sprintf(self::KEY_ENTITY_STATE, $identifier->getMachine(), $identifier->getEntityId());
            $redis->set($key, $state);
            //set on current states set
            $key = sprintf(self::KEY_CURRENT_STATES, $identifier->getMachine(), $state);
            $redis->sadd($key, $identifier->getEntityId());
            $redis->exec();
        } catch (\Exception $e) {
            $redis->discard();
            throw new Exception(sprintf('query for inserting state failed: [%s]', $e->getMessage()), Exception::PERSISTENCE_LAYER_EXCEPTION);
        }
    }