UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'n20QScdhsFYTjTOQGHHOdM7ZycgVA7VHGNNOLs1zpdM='
WHERE
key_id = 'd0748461d1d2315d64ac1719834bea18539f40d933cab975a3b2af1163d4bfe9'
AND (
token = 'n20QScdhsFYTjTOQGHHOdM7ZycgVA7VHGNNOLs1zpdM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)