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