UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'AeB1IUYQM6F/YLAipcvDpgf29h2XaeYLyMS/Ce8AsEY='
WHERE
key_id = '51305b388e44237ffbf371234ae177b9f87a9a879086b1730f7f2f924176adc8'
AND (
token = 'AeB1IUYQM6F/YLAipcvDpgf29h2XaeYLyMS/Ce8AsEY='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)