UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'aKPsWXXHKmXO3f6DGqWxNn3k+nt9AFgShKrbSFRd5n4='
WHERE
key_id = '646a46b198090e88d127ef4e958d24147840e5822317e730f1e132aafee18b9a'
AND (
token = 'aKPsWXXHKmXO3f6DGqWxNn3k+nt9AFgShKrbSFRd5n4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)