UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ted0HG9YrwxypENYFRG4WDcaAEDmzzdySuMNPKjPuvc='
WHERE
key_id = '8ad85966d198ec3b8841f0593bd743ba124e4468dc67f80a597f2befd849b862'
AND (
token = 'ted0HG9YrwxypENYFRG4WDcaAEDmzzdySuMNPKjPuvc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)