UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'IKjX7bBpNDK64JeC0xByBFVM3CRW/JRE3gjZTtTf+S8='
WHERE
key_id = 'aa16532dcf29826271c80e3e0d7177477cd882265f7e16928b21ffdf7f72bc24'
AND (
token = 'IKjX7bBpNDK64JeC0xByBFVM3CRW/JRE3gjZTtTf+S8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)