UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'NesjSI+Q5Bqu8hN0cFXvkwxcv5NY1wGQUX05A5u7M+w='
WHERE
key_id = 'd45300157299f30ec142e8ccbf9c60afc02e2b2595b92e9710e235cbc6d88e5d'
AND (
token = 'NesjSI+Q5Bqu8hN0cFXvkwxcv5NY1wGQUX05A5u7M+w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)