UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Wg6ZliYjRQ3aU70CjESJot5KHf+w96jrWX11yEK9Fy0='
WHERE
key_id = 'a47ad9c08535ea048a0ccc8153afa7d799f14102ff7038aebff57436471ba76a'
AND (
token = 'Wg6ZliYjRQ3aU70CjESJot5KHf+w96jrWX11yEK9Fy0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)