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