UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'i7ef8s04WJvWNDgE+CdMPalS1Wy+0Wt1smBWG5BgYP8='
WHERE
key_id = '0f176666734c18c2511e6409d6c34a4563ce38f042f3ca425edf972bf086ea22'
AND (
token = 'i7ef8s04WJvWNDgE+CdMPalS1Wy+0Wt1smBWG5BgYP8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)