UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TZepissBRuja3lxcLM6VN53z8bmt+dDTcpKywzGKN0o=' 
WHERE 
  key_id = '335ad4a13ae291324b15bd8007ce43266ac9ed338995308069757c34c8810217' 
  AND (
    token = 'TZepissBRuja3lxcLM6VN53z8bmt+dDTcpKywzGKN0o=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043