UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'RI9r3mvc0Y1QjWZHO1LOPkVQjev92FS01aXd0CjmnX0='
WHERE
key_id = 'b17731cbc0e1a70f8bae620fb0577155e6754de2e1f82659786bde09e56b6323'
AND (
token = 'RI9r3mvc0Y1QjWZHO1LOPkVQjev92FS01aXd0CjmnX0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)