UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'A2+OkcrfB6ztcww0h9IaAm0i8QK/0v5EUEo2COx9sx8='
WHERE
key_id = '9776e40922e8230e2c2839b237a0bc7057e63153263b2f3fe89483a6d24fb389'
AND (
token = 'A2+OkcrfB6ztcww0h9IaAm0i8QK/0v5EUEo2COx9sx8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)